A component which provide seamless integration of your plexus components with xwork Actions.
Your actions will a component with other components as requirement.
First is to add this component in your dependencies :
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-xwork-integration</artifactId>
<version>1.0-alpha-5</version>
</dependency>
Then you need to use the plexus-maven-plugin to generated the components.xml. Add this in your build section.
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
<configuration>
<roleDefaults>
<roleDefault>
<role>com.opensymphony.xwork.Action</role>
<instantiation-strategy>per-lookup</instantiation-strategy>
</roleDefault>
</roleDefaults>
</configuration>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
webWork configuration, add the following line in your webwork.properties :
webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory
You need to add a listener which will setup the Plexus Container (Note the plexus configuration runtime file used is META-INF/plexus/application.xml ) :
<listener>
<listener-class>org.codehaus.plexus.xwork.PlexusLifecycleListener</listener-class>
</listener>
Plexus properties are by default loaded from file /WEB-INF/plexus.properties (you can setup the path with the servlet context parameter plexus-properties)
Your action can extends PlexusActionSupport which provide an access to the Plexus Container.
Javadoc tags (see Plexus Component Descriptor Creator ) :
/**
* YourAction
*
* @plexus.component
* role="com.opensymphony.xwork.Action"
* role-hint="yourAction"
*/
public class YourAction
extends PlexusActionSupport
/**
* @plexus.requirement
* role-hint="default"
*/
private Component component;
Then in your webwork actions descriptor :
<action name="actionName" class="yourAction">
<result name="success">succes</result>
</action>
You can use other webWork stuff as Plexus Components :
Note : for some internal requirements Plexus holds a reference on each component created (instantiation-strategy=per-lookup). To prevent this leak, you can add an interceptor in your default interceptor stack (this interceptor will release your actions in the container) :
<interceptor name="plexusReleaseComponentInterceptor" class="plexusReleaseComponentInterceptor"/>