Class DefaultRequestContextFactory

java.lang.Object
swiss.trustbroker.common.tracing.DefaultRequestContextFactory
All Implemented Interfaces:
RequestContextFactory

public class DefaultRequestContextFactory extends Object implements RequestContextFactory
  • Constructor Details

    • DefaultRequestContextFactory

      public DefaultRequestContextFactory()
  • Method Details

    • create

      public RequestContext create(String calledObject, String calledMethod, String traceId, String principal, String clientId, Object fullRequestContext, Object fullResponseContext)
      Description copied from interface: RequestContextFactory
      Creates a new RequestContext with the given traceId and principal.
      Specified by:
      create in interface RequestContextFactory
      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

      public RequestContext create(String calledObject, String calledMethod, RequestContext context)
      Description copied from interface: RequestContextFactory
      Creates a new RequestContext based on the provided context.
      Specified by:
      create in interface RequestContextFactory
    • extendTransferId

      public RequestContext extendTransferId(String obj, String mth)
      Description copied from interface: RequestContextFactory
      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.
      Specified by:
      extendTransferId in interface RequestContextFactory
      Returns:
      current RequestContext with extended traceId
      See Also:
    • getNextTransferId

      public RequestContext getNextTransferId(String calledObject, String calledMethod)
      Description copied from interface: RequestContextFactory
      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.
      Specified by:
      getNextTransferId in interface RequestContextFactory
      Returns:
      unique traceId
    • getRequestContext

      public RequestContext getRequestContext()
      Description copied from interface: RequestContextFactory
      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.
      Specified by:
      getRequestContext in interface RequestContextFactory
      Returns:
      actual RequestContext or null if none exists
    • pushRequestContext

      public void pushRequestContext(RequestContext rc)
    • delete

      public void delete()
      Description copied from interface: RequestContextFactory
      Removes the last RequestContext from the request context stack. Any synchronous return statement (logInitialReturn, logReturn, logClientReturn) removes its RequestContext from the stack.
      Specified by:
      delete in interface RequestContextFactory
      See Also:
    • setRequestContext

      public void setRequestContext(RequestContext ctx)
      Description copied from interface: RequestContextFactory
      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.
      Specified by:
      setRequestContext in interface RequestContextFactory
      Parameters:
      ctx - new RequestContext which will be put onto the request context stack