I have found pipeline architectures to be one of the best ways of dividing up a problem. Unfortunately pipeline based frameworks seem extremely rare in the web world. I have come up with an extremely simple way to use pipelines that uses nothing but the core functionality of the servlet engine - a nonframework framework. Basically the idea is to use filters as pipeline components. I would be interested in feedback on this approach.
- Posted by: Ian Schumacher
- Posted on: October 20 2005 13:18 EDT
A year ago I created a very simplistic, Struts-like, MVC framework for an application. You essentially use a properties file to map URLs to sets of classes that are to be invoked in consecutive order - very much like a pipeline.
You can use a filter or a servlet as the controller for such a setup to load the properties in the init() method and then map incoming requests to the correct pipeline.
I assume you used a custom interface for the processing classes. I find it is very difficult to implement a pipeline structure with servlets (as the components, not the controller) because the lookup mechanisms have all been deprecated (one servlet can not look up and call another servlet directly). It almost looks as if servlets were meant to be pipelined at one time, but then Sun explicitly disabled this ability.
As pipeline components I used plain Java classes. Each class was tasked with a single piece of functionality ('action'), and adhered to simple interface that had one method in it with one paramter:
Information was passed between actions as attributes of the HttpServletRequest object which at the end of the pipeline was passed to a JSP that was responsible for displaying the result of the operation.
Tell me if you want more information.