Struts2

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
(The Struts2/Resin-IoC capability requires Resin 3.1.5)
 
(The Struts2/Resin-IoC capability requires Resin 3.1.5)
  
[http://struts.apache.org/2.x Struts2] can work with Resin-IoC to enable all Struts actions with WebBeans-style injection.  Your MyAction class can use the WebBeans @In and @Named annotations to retrieve beans defined in the resin-web.xml.
+
[http://struts.apache.org/2.x Struts2] can work with [http://caucho.com/resin-3.1/doc/resin-ioc.xtp Resin-IoC] to enable all Struts actions with WebBeans-style injection.  Your MyAction class can use the WebBeans @In and @Named annotations to retrieve beans defined in the resin-web.xml.
  
 
Optionally, you can define action classes as beans in the resin-web.xml to enable extra configuration if necessary.
 
Optionally, you can define action classes as beans in the resin-web.xml to enable extra configuration if necessary.

Revision as of 01:23, 12 January 2008

(The Struts2/Resin-IoC capability requires Resin 3.1.5)

Struts2 can work with Resin-IoC to enable all Struts actions with WebBeans-style injection. Your MyAction class can use the WebBeans @In and @Named annotations to retrieve beans defined in the resin-web.xml.

Optionally, you can define action classes as beans in the resin-web.xml to enable extra configuration if necessary.

The MyAction might look like:

 package example;

 import javax.webbeans.*;
 
 public class MyAction {
   @Named("wiki") DataSource _database;

   ...
 }

To enable Resin-IoC with Struts, you'll need to copy the resin/ext/resin-support.jar to either WEB-INF/lib or resin/ext-webapp. And you'll need to create or modify WEB-INF/classes/struts.properties as follows:

 # Tell struts to ask Resin for new action instances
 struts.objectFactory = com.caucho.xwork2.ResinObjectFactory

That's it. No other configuration is required to enable your actions for Resin-IoC.

Personal tools