}
private RuntimeEndpointReference setCallbackAddress(RuntimeEndpointReference endpointReference) {
try {
RuntimeEndpointReference epr = endpointReference;
if (callbackHandler.getCloneCallbackWire()){
epr = (RuntimeEndpointReference)endpointReference.clone();
}
// TUSCANY-3932
// If it's the default binding then we're going to look the callback endpoint
// up in the registry. Most remote protocols, which may be used as delegates
// for binding.sca, will expect to deal with absolute URLs so flip the
// callback endpoint back to force the lookup to happen
if (epr.getBinding().getType().equals(SCABinding.TYPE)){
// A/ create a callback endpoint to allow the
// callback lookup to take place
epr.setStatus(EndpointReference.Status.WIRED_TARGET_NOT_FOUND);
// if an endpoint it provided in the forward message use it or
// if not create one
if (resolvedEndpoint == null ){
RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
callbackEndpoint.setURI(callbackHandler.getCallbackTargetURI());
callbackEndpoint.setUnresolved(true);
epr.setTargetEndpoint(callbackEndpoint);
} else {
epr.setTargetEndpoint(resolvedEndpoint);
}
} else {
// B/ and C/ assume that the callback EPR is already resolved
// and set the binding URI if one is provided with the
// forward message. Some bindings may want to do other
// things to determine the callback URI to the
// CallbackHandler will be sent in the callback message
// header. This is particularly true if the clone isn't
// called above because resetting the URI will not
// be thread safe.
epr.setStatus(EndpointReference.Status.RESOLVED_BINDING);
if ( callbackHandler.getCallbackTargetURI() != null ){
epr.getBinding().setURI(callbackHandler.getCallbackTargetURI());
} else {
// do nothing and rely on whatever the user has configured
// in the SCDL
}
}