{
EndpointURI newUri = new MuleEndpointURI(newUriString, muleContext);
EndpointURI endpointURI = ep.getEndpointURI();
if (endpointURI != null && !newUri.getScheme().equalsIgnoreCase(endpointURI.getScheme()))
{
throw new CouldNotRouteOutboundMessageException(
CoreMessages.schemeCannotChangeForRouter(ep.getEndpointURI().getScheme(),
newUri.getScheme()), event, ep);
}
newUri.initialise();
return new DynamicURIOutboundEndpoint(ep, newUri);
}
catch (EndpointException e)
{
throw new CouldNotRouteOutboundMessageException(
CoreMessages.templateCausedMalformedEndpoint(uri, newUriString), event, ep, e);
}
catch (InitialisationException e)
{
throw new CouldNotRouteOutboundMessageException(
CoreMessages.templateCausedMalformedEndpoint(uri, newUriString), event, ep, e);
}
}
}
}