正在加载图片...
CHAPTER 1 INTRODUCTION TO THE EJBARCHITECTURE POJO Implementation EJB 3 took great strides to eliminate the trappings that beset enterprise bean classes and their required interfaces in earlier EJB releases.Similar to complaints over having to define XML metadata to specify even the most basic bean behavior,developers found it burdensome to have to write custom interfaces to handle an enterprise bean's factory support,and inconvenient to require a session bean's interfaces to extend EJB-specific interfaces.All of these limitations were addressed in EJB 3. Home methods are no longer mandated,although they're still supported.For session beans and MDBs,a default constructor replaces the no-argument ejbCreate()method required by earlier EJB specs. For entities,the Home interface is replaced by an EntityManagerFactory instance that produces EntityManager instances for a JPA persistence unit to manage entity life-cycle operations,including query executio Intelligent Use of Defaults or declar marking a P ay rriding the default bel atch the ame is the @Table annotation re uired.Gr has been taken to ensure that the default value atch so that.in the maiority of use case plicit m etadata is not ed.leading to lea more clutter-free code. Note One consequence of relying on default behavior is that the class does not describe its full behavior anywhere so you need to have a good understanding of the default behavior that is being applied.IDEs can be useful in deriving and displaying the enterprise bean or entity with its fully defaulted values explicitly shown. Distributed Computing Model Essential to any enterprise application is the ability to execute tasks and run components in separate Java threads or processes.Through the RMI-based remoting services,clients in an application client tier may access EJBs running in an application server anywhere on the network.The pass-by-value behavior of remote interface methods provides a coarse-grained model designed to reduce network traffic between clients and servers that are loosely connected to each other.Many applications that use EJB do not require remote access,however,and elect to configure their EJBs for local use.This eliminates the overhead of remote access support while continuing to offer the remaining enterprise services EJB Roles The EJB spec defines seven roles for individuals involved in the different stages of defining an enterprise beanor entity,or in providing services and API implementation to enter nse beans. This book is targete at the three role ing ente nd the ciated meta .In practice se rol s may De and y one role an nd th oning of ta lopment proces s.We will refer to Chapter 1 ■ Introduction to the EJB Architecture 7 POJO Implementation EJB 3 took great strides to eliminate the trappings that beset enterprise bean classes and their required interfaces in earlier EJB releases. Similar to complaints over having to define XML metadata to specify even the most basic bean behavior, developers found it burdensome to have to write custom interfaces to handle an enterprise bean’s factory support, and inconvenient to require a session bean’s interfaces to extend EJB-specific interfaces. All of these limitations were addressed in EJB 3. Home methods are no longer mandated, although they’re still supported. For session beans and MDBs, a default constructor replaces the no-argument ejbCreate() method required by earlier EJB specs. For entities, the Home interface is replaced by an EntityManagerFactory instance that produces EntityManager instances for a JPA persistence unit to manage entity life-cycle operations, including query execution. Intelligent Use of Defaults An excellent example of how EJB 3 simplifies the development process is its leveraging of default behavior to provide rich functionality with no coding or declarative metadata required. For instance, by simply marking a POJO with the @Entity annotation, all of its public properties automatically become persistent fields, and the table and column names take on derived values that match the entity and field names. Additional annotations or XML elements are only required when overriding the default behavior of a particular area. Only when the table name does not match the entity name is the @Table annotation required. Great care has been taken to ensure that the default values match the most common usages so that, in the majority of use cases, explicit metadata is not required, leading to leaner, more clutter-free code. ■ Note One consequence of relying on default behavior is that the class does not describe its full behavior anywhere, so you need to have a good understanding of the default behavior that is being applied. IDEs can be useful in deriving and displaying the enterprise bean or entity with its fully defaulted values explicitly shown. Distributed Computing Model Essential to any enterprise application is the ability to execute tasks and run components in separate Java threads or processes. Through the RMI-based remoting services, clients in an application client tier may access EJBs running in an application server anywhere on the network. The pass-by-value behavior of remote interface methods provides a coarse-grained model designed to reduce network traffic between clients and servers that are loosely connected to each other. Many applications that use EJB do not require remote access, however, and elect to configure their EJBs for local use. This eliminates the overhead of remote access support while continuing to offer the remaining enterprise services. EJB Roles The EJB spec defines seven roles for individuals involved in the different stages of defining an enterprise bean or entity, or in providing services and API implementation to enterprise beans. This book is targeted at the three roles involved in defining enterprise beans and their associated metadata. In practice, one or more of these roles may be performed by the same individual, and certain tasks may be performed by one role and overridden by another; but it is useful to understand the logical partitioning of tasks in the EJB development process. We will refer to these roles in various sections throughout the book
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有