Thursday, December 18, 2008

Chain of Resposibility and RequestPreprocessor

In Struts prior to version 1.3, RequestPreprocessor was used to handle all request processing. And a custom implementation of any of the process methods needed the request preprocessor to be subclassed.

Version 1.3 onwards, Struts started using Commons Chain library which provides an implementation of Chain of Responsibility(CoR).

CoR pattern models computation as a series of commands combined into a chain. Each command will be executed sequentially till it reached the last command. Filters are examples of CoR, which will also traverse back after reaching the end of the chain.

Ver 1.3 onwards, Struts uses ComposableRequestProcessor, which uses the Commons Chain library.ComposableRequestProcessor extends RequestPreprocessor and overides init and process methods. The commands for the process method is configurable using chain-config.xml.

Check out the links for more details
1. Part 1 CoR
2. Part 2 CoR

Reference: Struts the complete reference by James Holmes

No comments: