private void invokeLocal(Exchange exchange) throws HandlerException {
// Figure out the QName for the service were invoking
QName serviceName = getTargetServiceName(exchange);
// Get a handle for the reference and use a copy of the exchange to invoke it
ServiceReference ref = exchange.getProvider().getDomain().getServiceReference(serviceName);
if (ref == null) {
throw SCAMessages.MESSAGES.serviceReferenceNotFoundInDomain(serviceName.toString(), exchange.getProvider().getDomain().getName().toString());
}
SynchronousInOutHandler replyHandler = new SynchronousInOutHandler();
Exchange ex = ref.createExchange(exchange.getContract().getProviderOperation().getName(), replyHandler);
// Can't send same message twice, so make a copy
Message invokeMsg = exchange.getMessage().copy();
exchange.getContext().mergeInto(invokeMsg.getContext());
// Since this invocation may cross application boundaries, we need to set the TCCL
// based on the target service's application class loader
ClassLoader origCL = null;
try {
ClassLoader targetCL = (ClassLoader)
ref.getDomain().getProperty(Deployment.CLASSLOADER_PROPERTY);
origCL = Classes.setTCCL(targetCL);
ex.send(invokeMsg);
} finally {
if (origCL != null) {
Classes.setTCCL(origCL);