Struts2

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(New page: (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 WebBea...)
 
Line 1: Line 1:
 
(The Struts2/Resin-IoC capability requires Resin 3.1.5)
 
(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.
+
[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.
  
 
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.
Line 17: Line 17:
 
   }
 
   }
  
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/struts.properties as follows:
+
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
 
   # Tell struts to ask Resin for new action instances

Revision as of 19:04, 23 December 2007

(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