Package swiss.trustbroker.common.tracing
Class DefaultRequestContextFactory
java.lang.Object
swiss.trustbroker.common.tracing.DefaultRequestContextFactory
- All Implemented Interfaces:
RequestContextFactory
-
Constructor Summary
Constructors -
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 calledObject, String calledMethod) Creates a new RequestContext with an extended traceId.Used to get the actual RequestContext from the top of the request context stack.voidvoidPuts the RequestContext onto the request context stack.
-
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:RequestContextFactoryCreates a new RequestContext with the given traceId and principal.- Specified by:
createin interfaceRequestContextFactory- 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
Description copied from interface:RequestContextFactoryCreates a new RequestContext based on the provided context.- Specified by:
createin interfaceRequestContextFactory
-
extendTransferId
Description copied from interface:RequestContextFactoryPuts 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:
extendTransferIdin interfaceRequestContextFactory- Returns:
- current RequestContext with extended traceId
- See Also:
-
getNextTransferId
Description copied from interface:RequestContextFactoryCreates 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:
getNextTransferIdin interfaceRequestContextFactory- Returns:
- unique traceId
-
getRequestContext
Description copied from interface:RequestContextFactoryUsed 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:
getRequestContextin interfaceRequestContextFactory- Returns:
- actual RequestContext or null if none exists
-
pushRequestContext
-
delete
public void delete()Description copied from interface:RequestContextFactoryRemoves the last RequestContext from the request context stack. Any synchronous return statement (logInitialReturn, logReturn, logClientReturn) removes its RequestContext from the stack.- Specified by:
deletein interfaceRequestContextFactory- See Also:
-
setRequestContext
Description copied from interface:RequestContextFactoryPuts 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:
setRequestContextin interfaceRequestContextFactory- Parameters:
ctx- new RequestContext which will be put onto the request context stack
-