EJBs and Resource Manager Connection Factories
An EJB's participation in a messaging exchange begins with the resource manager. A resource manager is a J2EE component that manages the life cycle of a resource type, from connection pooling to transaction support to network communication. Through JNDI, the resource manager obtains factory objects called resource manager connection factories, which the container manages and maintains. EJBs use these resource manager connection factories to access extra-container resources (standard enterprise components that are not a core part of a J2EE container). JMS sessions and JavaMail sessions are among the resources an EJB can access with resource manager connection factories.
The EJB API uses the factory design pattern to provide access to resource manager connection objects. The factory pattern uses one class object (the factory) that returns references to objects of another class. This way, the factory class encapsulates the management of the resource connection objects, allowing caching, object recycling, and other types of optimizations. Additionally, the factory pattern separates the container's implementation from the EJB code, allowing the maximum degree of extensibility and scalability.
The information corresponding to a resource manager connection factory is described in the bean's deployment descriptor:
<description> This is a textual description of
The <res-ref-name> element identifies the JNDI name to which the connection factory reference should be bound. It is this name that is used in the enterprise bean code to obtain a reference. The <res-type> element indicates the factory object type. The <res-auth> and <res-sharing-scope> elements declare how the factory will be managed.
Two of the elements, <description> and <res-sharing-scope>, are optional.