From Resin 3.0

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.

  1. download Resin from http://caucho.com/download
  2. unzip resin into /usr/local/share/resin
  3. create /usr/local/share/resin/webapps/spring/WEB-INF/lib
  4. copy the Spring jars into WEB-INF
  5. start Resin with "java -jar /usr/local/share/resin/lib/resin.jar"

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 WEB-INF/resin-web.xml, you can configure Spring's listener to use Resin as the parent ApplicationContext as follows:

 <web-app xmlns="http://caucho.com/ns/resin">

   <database name="jdbc/mysql">
   <context-param parentContextKey="resin-webbeans-factory"/>



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


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


For a FooBean:

 package qa;

 import javax.sql.DataSource;

 public class FooBean {
   private DataSource _database;

   public void setDatabase(DataSource database)
     _database = database;

Spring and Quercus

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

  1. Create a test.php in webapps/spring/test.php as follows:

   $bean = spring_bean("foo");


Personal tools