Spring

From Resin 3.0

Revision as of 03:14, 14 January 2008 by Ferg (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Spring and Resin WebBeans

Spring can be configured to use Resin's WebBeans as a parent BeanFactory. This gives Spring access to any bean configured in Resin, including databases, EJBs, JMS items, and Resin <bean> items.

The resin-support.jar must be in the WEB-INF/lib (or ext-webapps)

The class of the ApplicationContext is com.caucho.spring.ResinApplicationContext.

In the resin-web.xml, you can configure Springs listener to use Resin as the parent ApplicationContext as follows:

 <web-app xmlns="http://caucho.com/ns/resin">
 
   <context-param parentContextKey="resin-webbeans-factory"/>

   <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>

 </web-app>

Spring beans defined in the applicationContext.xml can use Resin beans as <ref> values:

 <beans>

   <bean class="qa.FooBean" name="foo">
      <property name="database" ref="jdbc/mysql"/>
   </bean>

 </beans>


Spring and Quercus

Quercus PHP scripts can retrieve Spring beans using the spring_bean() method:

 $bean = spring_bean("foo");
Personal tools