Inserting Servlets in the Pipeline
All pipeline servlet classes directly or indirectly implement interface atg.servlet.pipeline.PipelineableServlet.
The PipelineableServlet interface has two sub-interfaces that provide more flexibility for inserting new servlets into the pipeline:
- atg.servlet.pipeline.InsertableServlet
- atg.servlet.pipeline.DispatcherPipelineableServlet
InsertableServlet
The InsertableServlet interface lets a servlet insert itself into the pipeline when the service starts, without requiring changes to servlets already in the pipeline, through the insertAfterServlet property, which points back to the preceding servlet. The inserted servlet reads the preceding servlet’s nextServlet property and points to it as the next servlet to execute after itself.
Here are the steps to add an InsertableServlet to the servlet pipeline:
1) Write your servlet by extending atg.servlet.pipeline.InsertableServletImpl
package com.foo.endeca.assembler;
import java.io.IOException;
import javax.servlet.ServletException;
import atg.core.util.StringUtils;
import atg.eai.framework.toolkit.IdLookup;
import atg.servlet.DynamoHttpServletRequest;
import atg.servlet.DynamoHttpServletResponse;
import atg.servlet.pipeline.InsertableServletImpl;
public class SearchkeywordRedirectPipeline extends InsertableServletImpl {
public void service(DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException {
String searchTerm = null;
searchTerm = request.getParameter("Ntt");
//Business logic goes here
logDebug("URL for searchTerm : " + searchTerm);
passRequest(request, response);
}
2) Define the servlet as a globally scoped Nucleus component
$class=com.foo.endeca.assembler.SearchkeywordRedirectPipeline
$scope=global
insertAfterServlet=/atg/dynamo/servlet/dafpipeline/CookieBufferServlet
Set the insertAfterServlet property of your servlet to point to the path of the pipeline servlet you want your servlet to follow. For example, you can insert a servlet after CookieBufferServlet as follows:
insertAfterServlet=/atg/dynamo/servlet/dafpipeline/CookieBufferServlet
When the inserted servlet finishes processing, it calls the method passRequest() (defined in InsertableServletImpl), which automatically passes the request and response objects to the next servlet in the pipeline.
Servlet Pipeline - All pipeline servlets in order of execution
You
can use the Dynamo Server Admin Component Browser to view request
handling pipeline servlets and their sequence within the pipeline:
Component path: /atg/dynamo/servlet/dafpipeline/DynamoHandler/
/atg/dynamo/servlet/dafpipeline/DynamoHandler
/atg/multisite/SiteContextPipelineServlet
/atg/dynamo/servlet/dafpipeline/SecurityServlet
/atg/dynamo/servlet/dafpipeline/TransactionServlet
/atg/dynamo/servlet/dafpipeline/ThreadUserBinderServlet
/atg/dynamo/servlet/dafpipeline/PathAuthenticationServlet
/atg/dynamo/servlet/dafpipeline/URLArgumentServlet
/atg/dynamo/servlet/dafpipeline/DynamoServlet
/atg/dynamo/servlet/dafpipeline/ProfileRequestServlet
/orion/locale/servlet/UpdateLocaleServlet
/orion/location/servlet/UpdateLocationServlet
/atg/dynamo/servlet/dafpipeline/ProfilePropertyServlet
/atg/dynamo/servlet/dafpipeline/SessionEventTrigger
/atg/dynamo/servlet/dafpipeline/SiteSessionEventTrigger
/atg/search/servlet/pipeline/SearchClickThroughServlet
/atg/dynamo/servlet/dafpipeline/PageViewServletTrigger
/atg/dynamo/servlet/dafpipeline/SessionSaverServlet
/atg/dynamo/servlet/dafpipeline/AccessControlServlet
/atg/dynamo/servlet/dafpipeline/PromotionServlet
/atg/dynamo/servlet/dafpipeline/CommerceCommandServlet
/atg/dynamo/servlet/pagecompile/DAFDropletEventServlet
/atg/dynamo/servlet/dafpipeline/MimeTyperServlet
/atg/dynamo/servlet/dafpipeline/ExpiredPasswordServlet
/atg/dynamo/servlet/dafpipeline/CookieBufferServlet
/foo/endeca/assembler/SearchkeywordRedirectPipeline - New Servlet
/atg/endeca/assembler/AssemblerPipelineServlet
/atg/dynamo/servlet/dafpipeline/MimeTypeDispatcher
dynamo-internal/html : /atg/dynamo/servlet/dafpipeline/FileFinderServlet
/atg/dynamo/servlet/dafpipeline/TailPipelineServlet