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
Thursday, December 18, 2008
Wednesday, December 17, 2008
Command Pattern & Servlets
Another use of Command pattern is in the Servlet. Servlet's service method runs on a separate thread where as Servelts are singletons.
This limits the user from using instance level variables to share data among custom methods we write in the Servlet. One way to overcome this is to use command pattern. Declare the command interface and an anonymous class using the interface within the service method. Invoke the command class from within the service method.
The command object can have different methods and can access instance variables of command class.
Check out this site
This limits the user from using instance level variables to share data among custom methods we write in the Servlet. One way to overcome this is to use command pattern. Declare the command interface and an anonymous class using the interface within the service method. Invoke the command class from within the service method.
The command object can have different methods and can access instance variables of command class.
Check out this site
Java Servlet basics - Interesting site
While I started brushing up the basics, came across an interesting doc on Servlet.
Subscribe to:
Posts (Atom)