Java Reference
In-Depth Information
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
<bean id="postageService"
class="com.apress.springenterpriserecipes.post.PostageServiceImpl" />
</beans>
The final step is to tell the EJB support class where your bean configuration is. By default, it looks at
the JNDI environment variable
java:comp/env/ejb/BeanFactoryPath
for the file location. So, you add an
environment entry to your EJB deployment descriptor for this location.
<ejb-jar>
<enterprise-beans>
<session>
<display-name>PostageService</display-name>
<ejb-name>PostageService</ejb-name>
<home>com.apress.springenterpriserecipes.post.PostageServiceHome</home>
<remote>com.apress.springenterpriserecipes.post.PostageServiceRemote
➥
</remote>
<ejb-class>
com.apress.springenterpriserecipes.post.PostageServiceBean
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>beans-ejb.xml</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
The EJB support classes instantiate the Spring IoC container using
BeanFactoryLocator
. The default
BeanFactoryLocator
they use is
ContextJndiBeanFactoryLocator
, which instantiates the IoC (a regular
BeanFactory
implementation such as
ApplicationContext
) container using a bean configuration file
specified by the JNDI environment variable
java:comp/env/ejb/BeanFactoryPath
. You can override
this variable name by calling the
setBeanFactoryLocatorKey()
method in a constructor or in the
setSessionContext()
method.
Now you can repack your EJB JAR file to include the preceding bean configuration file and redeploy
it to your EJB container. In OpenEJB, this is a simple undeploy and redeploy sequence. It will vary from
container to container.
Search WWH ::
Custom Search