return proxyFactory.createCallbackProxy(businessInterface, wires);
}
}
public RuntimeWire selectCallbackWire(Message msgContext) {
EndpointReference callbackEPR = getCallbackEndpoint(msgContext);
if (callbackEPR == null) {
return null;
}
//FIXME: need a cache for better performance. This requires making this
// method non-static, which means changing the signature of createCallbackProxy().
// first choice is wire with matching destination endpoint
for (RuntimeWire wire : wires) {
if (callbackEPR.getURI().equals(wire.getTarget().getURI())) {
try {
return (RuntimeWire)wire.clone();
} catch (CloneNotSupportedException e) {
throw new ServiceRuntimeException(e);
}
}
}
// no exact match, so find callback binding with same name as service binding
EndpointReference to = msgContext.getTo();
if (to == null) {
//FIXME: need better exception
throw new RuntimeException("Destination for forward call is not available");
}
for (RuntimeWire wire : wires) {
if (wire.getSource().getBinding().getName().equals(to.getBinding().getName())) {
//FIXME: need better way to represent dynamic wire
if (wire.getTarget().getURI().equals("/")) { // dynamic wire
//FIXME: avoid doing this for genuine dynamic wires
return cloneAndBind(msgContext, wire);
}
//FIXME: no dynamic wire, so should attempt to create a static wire
}
}
// no match so far, so find callback binding with same type as service binding
for (RuntimeWire wire : wires) {
if (wire.getSource().getBinding().getClass() == to.getBinding().getClass()) {
//FIXME: need better way to represent dynamic wire
if (wire.getTarget().getURI().equals("/")) { // dynamic wire
//FIXME: avoid doing this for genuine dynamic wires
return cloneAndBind(msgContext, wire);
}