The atg.servlet.pipeline package provide interfaces for creating request
handling pipeline servlets, All classes are directly or indirectly implement
interface atg.servlet.pipeline.PipelineableServlet.
Add InsertableServlet to the servlet pipeline:
Step 1:
|
Write your servlet, extending atg.servlet.pipeline.PipelineableServletImpl.
import
javax.servlet.*;
import
javax.servlet.http.*;
import java.io.*;
import
atg.servlet.*;
import
atg.servlet.pipeline.*;
public class
MyServlet extends PipelineableServletImpl {
public
MyServlet () {}
public void
service (DynamoHttpServletRequest request,
DynamoHttpServletResponse response)
throws IOException, ServletException
{
String pathInfo = request.getPathInfo ();
//
Insert here own logic
passRequest (request, response);
}
}
|
Step 2:
|
Define global scope component in the Nucleus hierarchy. It does not
really matter where you put your servlet in the component hierarchy (though
the location affects references to other components if you use relative
pathnames)
|
Step 3:
|
Set the nextServlet property of your servlet to point
to the path of the pipeline servlet you want your servlet to follow. For
example, if you want your servlet to follow the DynamoServlet in
the pipeline, use: nextServlet=/atg/dynamo/servlet/dafpipeline/DynamoServlet
|
Step 4:
|
Add the path to your servlet to the initialServices property
of /atg/dynamo/servlet/Inital.initialServices
initialService+=/MyServlet
|
The PipelineableServlet interface has two sub-interface that provide
more fexibility for inserting new servlet into pipeline. See in below diagram.
Add InsertableServlet to the servlet pipeline:
Step 1:
|
Write your servlet by extending
atg.servlet.pipeline.InsertableServletImpl.see in below example
|
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);
}
}
|
|
Step 2:
|
Define the servlet as a globally scoped Nucleus component
|
Step 3:
|
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 DynamoServlet as
follows:
insertAfterServlet=/atg/dynamo/servlet/dafpipeline/DynamoServlet
|
Step 4:
|
Add the servlet’s path to the initialServices property
of /atg/dynamo/servlet/Initial:initialServices+=/URIPrinter
|
1 comment:
nice
Post a Comment