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.
Monday, July 28, 2008
Share the thoughts
I thought for a while, when Shinu asked me to start blogging, what do I want to share and discuss with the world. Is this the right way to decipher my thoughts? Is this the way to keep track of my daily notes? Lets leave it to the days to come...
As time is spreading out from the magic lamp of life, this may make the days more brighter.
As time is spreading out from the magic lamp of life, this may make the days more brighter.
Subscribe to:
Posts (Atom)