rest spring aop resteasy jersey

Spring has a nice feature, which is often overlooked: a bean with shorter life-cycle can be injected into a bean with a longer life-cycle. A classic example is singleton for MVC controller and a request-scope bean for DAL. This is achieved in Spring with defining a proxy bean like this:

 

<bean id="booksDao" class="my.dal.BooksDao" scope="request">
  <aop:scoped-proxy />
</bean>

<bean id="booksFacade" class="my.web.BooksFacade">
  <property name="dao" ref="booksDao"/>
</bean>

 

This way, booksDao can be accessible from any beans processing the request, and Spring will ensure it's the same instance during the same request, and different instance for different requests.

 

andrew 28/12/2010 - 18:26
Syndicate content