Package swiss.trustbroker.common.tracing
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 Summary
Modifier and TypeMethodDescriptioncreate(String calledObject, String calledMethod, String traceId, String principal, String clientId, Object fullRequestContext, Object fullResponseContext) Creates a new RequestContext with the given traceId and principal.create(String calledObject, String calledMethod, RequestContext context) Creates a new RequestContext based on the provided context.voiddelete()Removes the last RequestContext from the request context stack.extendTransferId(String obj, String mth) Puts a new RequestContext with an extended traceId onto the request context stack.getNextTransferId(String obj, String mth) Creates a new RequestContext with an extended traceId.Used to get the actual RequestContext from the top of the request context stack.voidPuts the RequestContext onto the request context stack.
-
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 namecalledMethod- method called or request URL or SQL querytraceId- traceId that will be set for the RequestContextprincipal- userPrincipal to set for the RequestContextclientId- clientId to set for the RequestContextfullRequestContext- injection point dependent data (e.g. the HttpServletRequest)- Returns:
- newly created RequestContext
-
create
Creates a new RequestContext based on the provided context. -
extendTransferId
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
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
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:
-