protected Object invoke(Exchange exchange,
Object serviceObject,
Method m,
List params) {
// set up the webservice request context
MessageContext ctx =
ContextPropertiesMapping.createWebServiceContext(exchange);
Map< String, Scope > scopes = CastUtils.cast((Map< ?, ? >)ctx.get(WrappedMessageContext.SCOPES));
Map< String, Object > handlerScopedStuff = new HashMap< String, Object >();
if (scopes != null) {
for (Map.Entry< String, Scope > scope : scopes.entrySet()) {
if (scope.getValue() == Scope.HANDLER) {
handlerScopedStuff.put(scope.getKey(), ctx.get(scope.getKey()));
}
}
for (String key : handlerScopedStuff.keySet()) {
ctx.remove(key);
}
}
WebServiceContextImpl.setMessageContext(ctx);
List< Object > res = CastUtils.cast((List)super.invoke(exchange, serviceObject, m, params));
for (Map.Entry< String, Object > key : handlerScopedStuff.entrySet()) {
ctx.put(key.getKey(), key.getValue());
ctx.setScope(key.getKey(), Scope.HANDLER);
}
//update the webservice response context
ContextPropertiesMapping.updateWebServiceContext(exchange, ctx);
//clear the WebServiceContextImpl's ThreadLocal variable
WebServiceContextImpl.clear();
return res;
}
|