You can also modify a pipeline by inserting servlets that subclass atg.servlet.pipeline.InsertableServletImpl. InsertableServletImpl is an implementation of InsertableServlet that inserts itself into an existing servlet pipeline at startup. This capability is required because it is difficult to use Nucleus configuration files to splice into a pipeline whose configuration cannot be determined when the configuration files are written.

A servlet that implements InsertableServlet explicitly adds itself to a pipeline when the service starts, and uses the insertAfterServlet property to determine its location. Such a servlet may be the first servlet in its own secondary servlet pipeline, in which case it will have a nextServlet property. If so, it inserts itself into the primary pipeline after the insertAfterServlet servlet by changing that servlet’s nextServlet property to the InsertableServlet servlet. Then, the InsertableServlet servlet changes the nextServlet property of the last servlet in the secondary pipeline to point to the next servlet in the primary pipeline.

To add an InsertableServlet to the servlet pipeline:

Note: Subclasses of InsertableServletImpl that need to add their own logic to doStartService should be sure to call super.doStartService() at some point.

When your servlet finishes processing, it passes the request and response objects to the next servlet in the pipeline. InsertableServletImpl defines a method called passRequest, which automatically passes the request and response objects to the next servlet in the pipeline.

The following is an example of a pipeline servlet that prints the request URI before passing the request on to the next servlet in the pipeline:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import atg.servlet.*;
import atg.servlet.pipeline.*;

public class URIPrinter extends InsertableServletImpl {
  public URIPrinter () {}
  public void service (DynamoHttpServletRequest request,
                       DynamoHttpServletResponse response)
       throws IOException, ServletException
  {
    System.out.println ("Handling request for " +
                        request.getRequestURI ());
    passRequest (request, response);
  }
}
 
loading table of contents...