Apache Struts 2 Documentation > Home > Guides > Core Developers Guide > Struts2 Plugin |

Apache Struts 2 Documentation
Struts2 Plugin
Edit Page Browse Space Add Page Add News
Added by tm_jee, last edited by tm_jee on Oct 13, 2006 (view change)

Struts2 introduced the notion of plugins where by jar files with an optional 'struts2-plugin.xml' in its classpath could just be dropped into the container's classpath and gets picked up and integrated by Struts2.

| WARNING: Struts2 plugin has no concept of dependencies and it is advised that struts2 plugin developed should not have inter-dependencies among other Struts2 plugin except on Struts2 core.

## Concept

Struts2 plugin in similar in concept as a jar file. Struts2 plugin however, allows its plugin to have an optional struts2-plugin.xml in the classpath, if the plugin require some interceptor, action or results of its own to be recongnized by Struts2.

Struts2 load configuration files according to the followings (in descending priority order) :-

- struts-default.xml (provided in struts2 jar file)
- struts2-plugin.xml (provided by various plugin jar file)
- struts.xml (provided by webapp, should reside in webapp's classpath)

The structure of struts-plugin.xml looks exactly like struts-default.xml or struts.xml. It was done in such a way to allow most flexibility. One definition for all struts2 configuration.

## Examples

### Sitemesh plugin

Take Struts2 sitemesh plugin for example.

| Sitemesh is an extremely powerful and popular webapp decorator framework by OpenSymphony. More information about Sitemesh could be found here

Sitemesh plugin has the following structure

    + META-INF/
       + manifest.mf
     + org
       + apache
         + struts2
           + sitemesh
             + FreeMarkerPageFilter.class
             + TemplatePageFilter.class
             + VelocityPageFilter.class

Sitemesh plugin doesn need any struts components (like interceptor, result etc) to be registered with Struts2, as such it looks just like an ordinary jar file.

### Tiles plugin

Take Struts2 Tiles plugin for example, which has the following structure :-

    + META-INF/
       + manifest.mf
     + org
       + apache
         + struts2
           + tiles
             + StrutsTilesListener.class
             + StrutsTileUtilImpl.class
           + views
             + tiles
               + TilesResult.class
       + struts2-plugin.xml

Struts2 tiles plugin register some additional Struts2 component through its struts2-plugin.xml configuration within the jar file itself.