Spring
From Resin 3.0
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.
- download Resin from http://caucho.com/download
- unzip resin into /usr/local/share/resin
- create /usr/local/share/resin/webapps/spring/WEB-INF/lib
- copy the Spring jars into WEB-INF
- 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"> .... </database> <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>
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.
- Create a test.php in webapps/spring/test.php as follows:
<?php $bean = spring_bean("foo"); var_dump($bean); ?>