Thursday, July 23, 2015

Oracle ATG Controller Framework

  •  Introduction to Servlet Pipeline

            Oracle ATG Controller Framework is used to handle how HTTP requests are processed. Basically, It performs tasks like session tracking, page compilation etc. Controller includes series of separable servlets which has its own individual task, so called as Servlet Pipeline.
    This series of steps is dependent very much on sequence in which servlets are placed because of the information flow of request. Each servlet processes the request and may have input to next servlet.
    • Request Processing by Servlet Pipeline

    While processing a request in ATG, every step or task is a Nucleus component which implements Servlet interface. It is organized in linked list kind of data structure and is called a request-handling pipeline.
    Whenever request comes to the pipeline it is handled by the pipeline in a component oriented manner i.e. by having servlets as independent elements.
    ATG Provides Out of the Box pipeline to handle request which is used to process each request to application. It is started by a Page filter and requests which are coming to Nucleus are dispatched to PageFilter or DynamoProxyServlet. And it then follows the order of servlets in series.
    Here, each of these servlets perform their function on the request. Also, servlet is configured with a reference to the next servlet in pipeline. So, when a first servlet is processed on the request, it will pass the request to the next servlet and so on.
    ATG also provides flexibility of customizing the pipeline through components. These components are configurable and use Out of the Box provisions to execute in sequential manner.

    Below is the example of ATG Out of the Box Pipeline.

    • Example with Out of the Box Pipeline
      Dynamo Servlet Pipeline
    • How to customize Servlet Pipeline
    Every servlet in pipeline implement atg.servlet.pipeline.PipelineableServlet interface. 
    When we implement PipelineableServlet, it inherits a nextServlet property. This property is used to point to the next servlet component to invoke. 
    The pipeline components created should be scoped as global. Also, they need to be configured into pipeline.
    PipelineableServlet interface has two subinterfaces.  These two types provide additional features for determining the next component to invoke.
    1. InsertableServlet 

    This interface has a property called insertAfterServlet to enable the servlet to insert itself in a specific position in the pipeline. This mechanism is useful when you donot want to change or modify existing pipeline configurations and insert silently.

    package com.myapp;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import atg.servlet.*;
    import atg.servlet.pipeline.*;
    public class MyServllet extends InsertableServletImpl {

    public MyServlet () {}

    public void service (DynamoHttpServletRequest request,DynamoHttpServletResponse response)throws IOException, ServletException {
    System.out.println ("Inside MyServlet with request " +request.getRequestURI ());
    passRequest (request, response);

    Here, MyServlet will be inserted after DynamoServlet

    2. DispatcherPipelineableServlet 

    This interface provide a mechanism to create branches of servlets using some condition.
    It is possible with dispatcherServiceMap property of this class, which is a map of servlets based on condition.
    Out of the box MimeTypeDispatcher servlet is used to determine which servlet needs to be invoked based on the MIME type of the request.

    No comments:

    Post a Comment