|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ConnectorRequestInterceptor
A request interceptor. An interceptor allows intercepting the request created by a connector.
See handleInvocation(ConnectorInvocation) for more details and usage patters.
The interceptor is invoked for every request created by a connector. As such, an interceptor implementation must be thread-safe.
| Method Summary | |
|---|---|
Object |
handleInvocation(ConnectorInvocation invocation)
Intercept and handle the actual invocation. |
| Method Detail |
|---|
Object handleInvocation(ConnectorInvocation invocation)
throws Exception
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();
}
invocation - the invocation
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||