Java Reference
In-Depth Information
<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>
com/apress/einsure/business/ejbfacade/Underwriting-beans.xml
</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>UnderwritingRemoteBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
As I mentioned earlier, with Spring EJB support it is possible to start an application
context. The default mechanism is to load an application context from a resource speci-
fied as a JNDI environment variable: java:comp/env/ejb/BeanFactoryPath . Listing 4-18
highlights this environment variable. This default behavior is provided with the help of
the BeanFactoryLocator implementation provided by the ContextJndiBeanFactoryLocator
class. It is also possible to provide a custom BeanFactoryLocator implementation and
inject it using the setBeanFactoryLocator method either in the setSessionContext method
or in the default constructor of the stateless session bean implementation class.
The default behavior of ContextJndiBeanFactoryLocator can have serious performance
limitations. Loading and initializing an application context with several beans defined in
it can be time-consuming. You can overcome this by using a shared bean factory for all
the EJBs. The ContextSingletonBeanFactoryLocator class provides this support. However,
you need to be careful with a singleton context and limit it only amongst the EJBs in your
application. Sharing a common application context amongst all tiers (presentation, busi-
ness, and integration) may result in lots of class-loading issues.
Listing 4-19 shows the Spring configuration file required to start the SLSB application
context. Currently, it does not contain any bean definition. I will put this to effective use
later when I discuss the Application Service pattern.
 
Search WWH ::




Custom Search