EJB factories (access beans)
An EJB factory is an access bean that simplifies the creating or finding of an enterprise bean instance.
An EJB factory encapsulates the function provided by two objects: an InitialContext and an enterprise bean's home interface. It allows you to set the provider URL and other settings needed to perform the enterprise bean home lookup operation. The superclass of the EJB factory hides the implementation details of performing the lookup in the name service and the PortableRemoteObject.narrow() operation needed to acquire the EJB home implementation. (Note that EJB factories are not serializable because they are helper classes used to obtain remote EJB instances.)
EJB factories are automatically generated whenever you choose to generate one of the following access bean types using the Add an Access Bean wizard:
- Java bean wrapper
- Copy helper
- Data class
The creation wizard allows you to specify a different Java package for the new factory class.
Note: An EJB factory is not created for an enterprise bean that only has a local client view.
Home interface mapping
The purpose of an EJB factory is to provide the means for creating references to enterprise bean remote objects. The factory class does this by implementing the methods of the enterprise bean's home interface and delegating those method calls to an instance of the enterprise bean's home. The factory class gets a reference to an EJBHome by performing a 'lookup' in a specific name service. You can direct the lookup call to any name service or use the default settings. When the first call is made to an EJBHome method, the instance will acquire the EJBHome object by performing the lookup operation.
JNDI mapping
A default JNDI name is generated into each access bean class. The code generator uses the JNDI name specified in the extensions editor, which by default is the home interface name. You can change the JNDI name using setJNDIName().Generally, you don't need to change the JNDI name. However, if an enterprise bean is deployed into a different home, the administrator may add a prefix to the JNDI name to indicate the difference. To look up a home, an access bean obtains a name service context known as the rootContext, which you can construct if you know the name service URL and the name service type. Access beans provide two APIs to set the properties of the rootContext:
- setInitialContextFactoryName()
- setInitialContextProviderURL()
Parent topic
enterprise beans and alleviate the performance problems associated with remote calls for multiple enterprise bean attributes.">Access beans