Java Reference
In-Depth Information
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