Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

Struts 1 provided a plugin class that provided listener-like capabilities. The Struts 2 plugins are like Eclipse or FireFox plugins, and not at all like Struts 1 "plugins".

The framework supports plugins that A Struts 2 plugin is a single JAR that class and/or configuration that extend, replace, or add to existing Struts framework functionality. A plugin can be installed by adding a JAR file to the application's class path. To configure the plugin, the JAR may contain a
struts-plugin.xml, which follows the same format as an ordinary struts.xml file.

Since a plugin can contain the struts-plugin.xml file, it has the ability to:

  • Define new packages with results, interceptors, and/or actions
  • Override framework constants
  • Introduce new extension point implementation classes

Many popular but optional features of the framework are distributed as plugins. An application can retain all the plugins provided with the distribution, or just include the ones it uses. Plugins can be used to organize application code or to distribute code to third-parties.

...

Since the struts.xml file is always loaded last, it can make use of any resources provided by the plugins bundled with the distribution, or any other plugins available to an application.

Extension Points

Extension points allow a plugin to override a key class in the Struts framework with an alternate implemention. For example, a plugin could provide a new class to create Action classes or map requests to Actions.

The following extension points are available in Struts 2:

Plugin Examples

Let's look at two similar but different plugins bundled with the core distribution.

...