Java Reference
In-Depth Information
The KodoJDODetachObjectCallback calls FetchConfiguration.getFields() to get
the set of currently active fields and then adds the specified fields. The finally
clause restores the set of current active fields to its original value.
At this point you know how to detach Hibernate and JDO objects. Next, let's
look at how to deploy a POJO façade using the Spring framework.
7.6 Deploying the POJO façade with Spring
In the fairytale of Jack and the Beanstalk, Jack traded his cow for some magic
beans. That fateful decision was the start of a thrilling adventure that included an
encounter with a homicidal giant and eventually led to a life of happiness for Jack
and his mother. Now I'm not promising that using Spring beans will result in life-
long happiness, but they will certainly make development a lot easier. The final
step of implementing a POJO façade is to write the Spring beans that deploy the
POJO façade in Spring's lightweight container.
We must write the Spring bean definitions that configure Spring to create the
POJO façade and make it transactional by wrapping it with an AOP interceptor.
The bean definitions describe how the Spring lightweight container should
instantiate the POJO façade and any objects that it requires. Spring's dependency
injection mechanism passes the required objects as either constructor arguments
or setter arguments. The bean definitions also describe how to apply the AOP
interceptors that make the POJO façade transactional.
To deploy the PlaceOrderFacade , we must define several kinds of beans. First,
we need to define Spring beans that instantiate the PlaceOrderFacade and the
classes that it needs, such as the PlaceOrderService and repositories. Second, we
must define beans that instantiate Spring classes such as TransactionInterceptor ,
and a PlatformTransactionManager that makes the PlaceOrderFacade transac-
tional. Third, we must define Spring beans that instantiate classes that enable the
application to access the database, such as an ORM template class and a persis-
tence framework connection factory. Figure 7.10 shows the beans required to
deploy the PlaceOrderFacade .
Some of those beans, such as the PlaceOrderFacade , the PlaceOrderService ,
and the TransactionInterceptor , are independent of the persistence framework.
Other beans are persistence framework-specific, including the repositories, the
PlaceOrderResultFactory , the PlatformTransactionManager , the ORM template
class, and the connection factory. I begin this section by describing the generic
bean definitions. After that, I will describe the Hibernate-specific and JDO -specific
bean definitions.
 
 
 
Search WWH ::




Custom Search