Name |
Guice Plugin |
---|---|
Publisher |
Apache Software Foundation |
License |
Open Source (ASL2) |
Version |
1.0.1 |
Homepage |
http://code.google.com/p/google-guice/ |
Download |
http://code.google.com/p/google-guice/downloads/list |
Source Code |
http://code.google.com/p/google-guice/source |
Guice User Guide |
http://google-guice.googlecode.com/files/Guice%201.0%20User's%20Guide.pdf |
Overview
The Guice plugin allows Actions, Interceptors, and Results to be injected by Guice
Requirements
- Struts 2.0.6+
Installation and Usage
To install the Guice Struts 2 plugin with Struts 2.0.6 or later, simply include guice-struts2-plugin-1.0.jar in your web application's classpath and select Guice as your ObjectFactory implementation in your struts.xml file:
Guice will inject all of your Struts 2 objects including actions and interceptors. You can even scope your actions. You can optionally specify a Module for Guice to install in your struts.xml file:
If all of your bindings are implicit, you can get away without defining a module at all.
1 Comment
James Williams
Nice plugin and works well once configured properly.
Adding
<constant name="struts.objectFactory" value="guice" />
to your struts.xml file may not work properly. I had a problem where my application was trying to use the spring object factory.
I had to change the value struts.objectFactory property in the application struts.properties file to "guice".
In addition if you want to use the Guice Servlet scopes you have to add an additional filter to your web.xml file.
<filter>
<filter-name>guiceServlet</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>