Class DebugRequestInterceptor
- All Implemented Interfaces:
ConnectorRequestInterceptor
A dummy debug connector, which saves the ConnectorRequest
(getRequest()
)
and the raw request (getTarget()
) for debugging purpose.
The boolean constructor flag determines whether the request invocation should be continued or aborted after this interceptor. Also it is possible to add a response object which will returned without further passing the interceptor chain;
- Author:
- Sebastian Menski
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDebugRequestInterceptor
(boolean proceed) DebugRequestInterceptor
(Object response) -
Method Summary
Modifier and TypeMethodDescription<T extends ConnectorRequest<?>>
T<T> T
<T> T
handleInvocation
(ConnectorInvocation invocation) Intercept and handle the actual invocation.boolean
void
setProceed
(boolean proceed) void
setResponse
(Object response)
-
Field Details
-
response
-
proceed
protected boolean proceed
-
-
Constructor Details
-
DebugRequestInterceptor
public DebugRequestInterceptor() -
DebugRequestInterceptor
public DebugRequestInterceptor(boolean proceed) -
DebugRequestInterceptor
-
-
Method Details
-
handleInvocation
Description copied from interface:ConnectorRequestInterceptor
Intercept and handle the actual invocation. An implementation of this method *must* call
invocation.proceed();
and return the result:public Object handleInvocation(ConnectorInvocation invocation) throws Exception { // do something before the request try { Object result = invocation.proceed(); // do something after a successful request return result; } catch(Exception e) { // do something after a failed request throw e; } }
This may be useful for "management" use cases such as logging, failure tracking etc... and modifying the Thread context of the request thread (Security Context, Transactions, ...).
It is also possible for an implementation to access and modify the low level "raw" request object before it is executed by the connector:
public Object handleInvocation(ConnectorInvocation invocation) throws Exception { Object rawRequest = invocation.getTarget(); // cast rawRequest to the low-level connector implementation object and work with it. // finally return invocation.proceed(); }
- Specified by:
handleInvocation
in interfaceConnectorRequestInterceptor
- Parameters:
invocation
- the invocation- Returns:
- the result of the invocation
- Throws:
Exception
-
setProceed
public void setProceed(boolean proceed) -
isProceed
public boolean isProceed() -
setResponse
-
getResponse
public <T> T getResponse() -
getRequest
-
getTarget
public <T> T getTarget()
-