Java Reference
In-Depth Information
Configuration defaults
Common expected behaviors and requirements for the EJB container are not
required to be specified by a developer. For example, by default an EJB 3.0 container
provides Container-Managed persistence and Container - Managed Transaction
( CMT ) demarcation. Default metadata values and programmatic defaults are
provided by the EJB 3.0 implementation. A "coniguration by exception" approach
is taken rather than explicit configuration. Relationship Mapping Defaults are
defined in the persistence API. Object/relational mapping defaults are also defined.
For example, an Entity bean is mapped to a database table name of the same name
as the capitalized entity class name. Therefore, an Entity class Catalog is mapped
to database table CATALOG by default. Similarly, the default column name is the
property or field name. The entity name defaults to the entity class name.
Environmental dependencies and
JNDI Access
An enterprise bean's context may be divided into 3 components:
• Container context
• Resources
• Environment context
The container may be used to supply references to resources and environment
entries. Environmental dependencies and JNDI access may be encapsulated with
dependency annotations, a dependency injection mechanism, and a simple lookup
mechanism. Dependency injection implies that the EJB container automatically
supplies/injects a bean's variable or setter method with a reference to a resource
or environment entry in the bean's context. Alternatively, you would have to use
the javax.ejb.EJBContext or JNDI APIs to access the environment entries and
resources. Dependency injection is implemented by annotating a bean's variable or
setter method with one of the following annotations:
@javax.ejb.EJB is used to specify dependency on another EJB.
@javax.annotation.Resource is used to specify dependency on an external
resource such as a JDBC datasource, a JMS destination, or a JMS connection
factory. The @Resource annotation is not specific to EJB 3, and may be also
used with other Java EE components.
Search WWH ::

Custom Search