* if necessary.
*
* @param message the current Message
*/
protected Conduit getSelectedConduit(Message message) {
Conduit c = findCompatibleConduit(message);
if (c == null) {
Exchange exchange = message.getExchange();
EndpointInfo ei = endpoint.getEndpointInfo();
String transportID = ei.getTransportId();
try {
ConduitInitiatorManager conduitInitiatorMgr = exchange.getBus()
.getExtension(ConduitInitiatorManager.class);
if (conduitInitiatorMgr != null) {
ConduitInitiator conduitInitiator =
conduitInitiatorMgr.getConduitInitiator(transportID);
if (conduitInitiator != null) {
String add = (String)message.get(Message.ENDPOINT_ADDRESS);
String basePath = (String)message.get(Message.BASE_PATH);
if (StringUtils.isEmpty(add)
|| add.equals(ei.getAddress())) {
c = conduitInitiator.getConduit(ei);
replaceEndpointAddressPropertyIfNeeded(message, add, c);
} else {
EndpointReferenceType epr = new EndpointReferenceType();
AttributedURIType ad = new AttributedURIType();
ad.setValue(StringUtils.isEmpty(basePath) ? add : basePath);
epr.setAddress(ad);
c = conduitInitiator.getConduit(ei, epr);
}
MessageObserver observer =
exchange.get(MessageObserver.class);
if (observer != null) {
c.setMessageObserver(observer);
} else {
getLogger().warning("MessageObserver not found");
}
} else {
getLogger().warning("ConduitInitiator not found: "
+ ei.getAddress());
}
} else {
getLogger().warning("ConduitInitiatorManager not found");
}
} catch (BusException ex) {
throw new Fault(ex);
} catch (IOException ex) {
throw new Fault(ex);
}
conduits.add(c);
}
if (c != null && c.getTarget() != null && c.getTarget().getAddress() != null) {
replaceEndpointAddressPropertyIfNeeded(message, c.getTarget().getAddress().getValue(), c);
}
//the search for the conduit could cause extra properties to be reset/loaded.
message.resetContextCache();
message.put(Conduit.class, c);
return c;