2

What is the correct scope for a DAF pipeline servlet component used for REST services (like ActorServlet)? Should it be set to global or request?

lipman
  • 101
  • 2
  • 7

1 Answers1

2

From the ATG Documentation:

If a component’s $scope property is not explicitly set, it automatically has global scope.

Looking at the ActorServlet in the Component Browser in dynadmin it shows that there is no explicit scope set so it should indicate it is global scope by default.

Looking into this a bit more, the ActorServlet (which is the component of the RestPipelineServlet) extends the the PipelineableServletImpl which implements the PipelineableServlet interface. Here there is an abstract method passRequest which forms part of the actual pipeline 'chain' being executed.

public abstract void passRequest(ServletRequest paramServletRequest, ServletResponse paramServletResponse)
throws IOException, ServletException;

This means you will always have access to the current request. In the PipelineableServletImpl it internally calls the service method.

public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws IOException, ServletException {
    //Insert your logic here
    passRequest(pRequest, pResponse);
}

You would normally override the service method and add your own logic in there but still have access to the current request which should indicate to you that, as long as the rest of your variables are thread safe, specifying your Pipeline Servlet as global scope is the correct way to go.

radimpe
  • 3,197
  • 2
  • 27
  • 46