A standard servlet pipeline (described in the previous section) is invoked every time Dynamo handles a request. An additional servlet pipeline is used by the Dynamo Administration interface. This pipeline starts at /atg/dynamo/servlet/adminpipeline/AdminHandler.

You can construct pipelines used by your own applications, or you can customize the existing pipelines in Dynamo by adding servlets. Note that components in a servlet pipeline should be globally scoped.

The atg.servlet.pipeline package provides interfaces that provide various mechanisms for linking servlets to create a pipeline. The heart of the servlet pipeline is the PipelineableServlet interface. All servlets in a pipeline must implement this interface. Servlets that implement PipelineableServlet have a nextServlet property that points to the next component to invoke. This is the primary pipelining mechanism used by the standard request-handling pipelines. Dynamo also provides an implementation class, PipelineableServletImpl, that implements this interface; your own classes can implement PipelineableServlet by subclassing PipelineableServletImpl.

The PipelineableServlet interface has two subinterfaces that provide additional mechanisms for determining the next component to invoke: InsertableServlet and DispatcherPipelineableServlet. Servlets that implement the InsertableServlet interface have an insertAfterServlet property that enables the servlet to insert itself in a specific spot in the pipeline. The key advantage of this mechanism is that it does not require modifying any existing servlets in the pipeline.

For example, suppose you have a servlet pipeline in which a servlet called Servlet1 invokes a servlet called Servlet2. Now suppose you want to insert another servlet, Servlet1a, between these two servlets in the pipeline. If Servlet1a implements PipelineableServlet, you can reroute the pipeline by changing the value of the Servlet1.nextServlet property so it points to Servlet1a rather than Servlet2, and set Servlet1a.nextServlet to point to Servlet2. But if Servlet1a implements InsertableServlet, all you have to do is set Servlet1a.insertAfterServlet to point to Servlet1, and Servlet1a will automatically be “spliced” into the pipeline right after Servlet1 and before Servlet2. Servlet1a is able to do this because it effectively sets its own nextServlet property to the value of Servlet1’s nextServlet property and rewrites Servlet1’s nextServlet property to point to Servlet1a.

The DispatcherPipelineableServlet interface provides a mechanism for conditionally branching the pipeline. This interface includes a dispatcherServiceMap property that is a Map of possible servlets to invoke next, depending on some condition. For example, the MimeTypeDispatcher servlet determines which servlet to invoke depending on the MIME type of the request.

Dynamo provides implementation classes for these subinterfaces as well. To implement the InsertableServlet interface, you can subclass InsertableServletImpl. To implement DispatcherPipelineableServlet, you can subclass DispatcherPipelineableServletImpl.

Note:When you add your own servlets to the servlet pipeline, bear in mind that you cannot access the session object until the SessionServlet locates or creates it. So, if you add a servlet to the pipeline that needs to access the session object, make sure that your servlet appears in the pipeline after the SessionServlet.

 
loading table of contents...