Interface RequestContextFactory

All Known Implementing Classes:
DefaultRequestContextFactory

public interface RequestContextFactory
Factory for getting hold of the currently valid request context. I.e. the context associated with the current user's current request.
  • Method Details

    • create

      RequestContext create(String calledObject, String calledMethod, String traceId, String principal, String clientId, Object fullRequestContext, Object fullResponseContext)
      Creates a new RequestContext with the given traceId and principal.
      Parameters:
      calledObject - called object or called servlet/filter or database name
      calledMethod - method called or request URL or SQL query
      traceId - traceId that will be set for the RequestContext
      principal - userPrincipal to set for the RequestContext
      clientId - clientId to set for the RequestContext
      fullRequestContext - injection point dependent data (e.g. the HttpServletRequest)
      Returns:
      newly created RequestContext
    • create

      RequestContext create(String calledObject, String calledMethod, RequestContext context)
      Creates a new RequestContext based on the provided context.
    • extendTransferId

      RequestContext extendTransferId(String obj, String mth)
      Puts a new RequestContext with an extended traceId onto the request context stack. This is done when a synchronous client call is done. Asynchronous client calls also get a RequestContext with an extended traceId but that RequestContext may not be put onto the request context stack. The client doing the asynchronous call must manage the returned RequestContext by itself.
      Returns:
      current RequestContext with extended traceId
      See Also:
    • getNextTransferId

      RequestContext getNextTransferId(String obj, String mth)
      Creates a new RequestContext with an extended traceId. Generates a new unique Transfer-Id. The new Transfer-Id is built by appending a process-wide unique Request-Id to the Transfer-Id stored in the current RequestContext on top of the request context stack. The resulting RequestContext is not put itself onto the request context stack. Asynchronous client calls use this method to get a RequestContext with an extended traceId.
      Returns:
      unique traceId
      Throws:
      IllegalArgumentException - when no RequestContext is available
    • getRequestContext

      RequestContext getRequestContext()
      Used to get the actual RequestContext from the top of the request context stack. It only returns the top of the stack it does not remove it.
      Returns:
      actual RequestContext or null if none exists
    • setRequestContext

      void setRequestContext(RequestContext rc)
      Puts the RequestContext onto the request context stack. Server side entering (logInitialEnter, logEnter) and the synchronous client side service invocation (logClientCall) statement put there RequestContext onto that stack. There corresponding return statements will later remove them form the stack again. NOTE: The request context stack itself is stored in a thread local.
      Parameters:
      rc - new RequestContext which will be put onto the request context stack
    • delete

      void delete()
      Removes the last RequestContext from the request context stack. Any synchronous return statement (logInitialReturn, logReturn, logClientReturn) removes its RequestContext from the stack.
      See Also: