Java Reference
In-Depth Information
<value>false</value>
</property>
<property name="proxyInterface">
<value>javax.persistence.
bbbbbbb bb EntityManager</value>
</property>
</bean>
Specifies object's type
<bean id="PendingOrderRepositoryImpl"
class="net.chrisrichardson.foodToGo.ejb3.domain.
bbb bb EJB3PendingOrderRepository">
<constructor-arg ref="EntityManager"/>
</bean>
</beans>
In this listing, the JndiObjectFactoryBean 's jndiName specifies the JNDI name of
the EntityManager . The “java:comp.ejb3/env” portion of the name is JB oss-specific,
and the “EntityManager” portion corresponds to the name specified by the @Per-
sistenceContext annotation on the session bean class.
Next, the lookupOnStartup property tells the JndiObjectFactoryBean to delay
performing the JNDI lookup until the EntityManager is first accessed. Then the
proxyInterface property specifies the type of the object that will be retrieved.
Finally, the <constructor-arg> element specifies that the EntityManager retrieved
from JNDI should be passed as a constructor parameter to the EJB3Pending-
OrderRepository .
That's it! We have gotten through all of gory details of using JDNI and JB oss
service POJO s. Once you have annotated the session beans, written the service
POJO to bind the references, and configured the Spring beans, the EJB and
Spring dependency injections can work side by side. Spring takes care of wiring
together arbitrary POJO s with their dependencies, and the EJB container injects
the POJO s into the EJB s. The main drawback of this approach is that quite a bit of
setup is involved, which is typical of EJB s. Instead of a simple lightweight mecha-
nism that Spring provides, we have to resort to the heavyweight JNDI mechanism.
It would be much better if EJB 3 was directly integrated with Spring.
Passes EntityManager
to constructor
10.4.3
Using Spring dependency injection
The third way to wire together the façade and its dependencies is for the session
bean to explicitly call the Spring bean factory, as shown in figure 10.5. With this
approach, the façade is the only stateless session bean. The other components,
such as the domain services and repositories, are POJO s.
 
 
 
Search WWH ::




Custom Search