SourceForge.net Logo
Version: 0.27 - Last update: 2004-05-30 Home Page - SourceForge Project Page - Contact

Jodd
  Overview
  News
  Download
  License
  References

Development
  Using Jodd
  Javadoc
  JUnit report

Community
  Contribute
  Report a bug

More reading
  Milestone 0.30



Top 25%

BSD
 

Action Filters

Implementation of ActionFilter interface may be used for intercepting actions invoking. Currently, there may be only one instance of the ActionFilter registered with controller. However, even it is one, ActionFilter may serve or even dispatch control to many others user-defined filters if needed.

ActionFilter defines 2 methods. One is invoked before action is invoked, and the second one after action was invoked.

ActionFilter.onAction() may influence invoking of the required action. If this method returns not-null string, than required action will not be invoked, and returned string will be used as action result, as it would be returned by action itself.

ActionFilter.onAfterAction() is called after the action was invoked and if not already intercepted by previous method. This method also may influence the returned action results, by returning not-null string.

Potentional usage

Here is the list of some potentional usage of the ActionFilter:
  • universal logger - for logging all actions without a need to do that in each action;
  • access rights control - access rights may be defined for each action in the configuration file as parameter, and filter may check this automatically;
  • having read-only mode for the application - for intercepting of all actions that writes something to the persistent storage, useful when application is under the maintains.

Some weird stuff :)

Just for the thinking:
  1. map all actions to one action servlet class
  2. use filter to handle the actions
And you got a custom controller that doesn't depend on ActionServlet classes.


http://jodd.sourceforge.net
najgor at users.sourceforge.net