this.operation = operation;
}
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
HandlerChain handlerChain = new HandlerChainImpl(handlerInfos);
try {
Object invocationResult = null;
try {
if (handlerChain.handleRequest(messageContext)) {
// update arguments as handlers could change the soap msg
context.setParameters(getArguments());
invocationResult = context.proceed();
// update the soap msg so that handlers see invocation result
if (!handlerChain.isEmpty()) {
createResult(invocationResult);
}
} else {
/* The Handler implementation class has the responsibility of setting
* the response SOAP message in the handleRequest method and perform
* additional processing in the handleResponse method.
*/
invocationResult = null;
}
} catch (SOAPFaultException e) {
handlerChain.handleFault(messageContext);
throw e;
}
handlerChain.handleResponse(messageContext);
if (!handlerChain.isEmpty()) {
/*
* Deserialize the result value from soap msg as handers could have
* changed it.
*/
try {
invocationResult = demarshallResult();
} catch (Exception e) {
// if this fails, return invocationResult from above
}
}
return invocationResult;
} finally {
handlerChain.destroy();
}
}