throws EndpointException
{
String uri = getReceiverName(httpServletRequest);
if (uri == null)
{
throw new EndpointException(
HttpMessages.unableToGetEndpointUri(httpServletRequest.getRequestURI()));
}
MessageReceiver receiver = getReceivers().get(uri);
// Lets see if the uri matches up with the last part of
// any of the receiver keys.
if (receiver == null)
{
receiver = HttpMessageReceiver.findReceiverByStem(connector.getReceivers(), uri);
}
if (receiver == null)
{
receiver = matchReceiverByWildcard(uri, receiver);
}
if (receiver == null)
{
throw new NoReceiverForEndpointException(uri);
}
InboundEndpoint endpoint = receiver.getEndpoint();
// Ensure that this receiver is using a dynamic (mutable) endpoint
if (!(endpoint instanceof DynamicURIInboundEndpoint))
{
endpoint = new DynamicURIInboundEndpoint(receiver.getEndpoint());
receiver.setEndpoint(endpoint);
}
// Tell the dynamic endpoint about our new URL
//Note we don't use the servlet: prefix since we need to be dealing with the raw endpoint here
EndpointURI epURI = new MuleEndpointURI(getRequestUrl(httpServletRequest), muleContext);
try
{
epURI.initialise();
epURI.getParams().setProperty("servlet.endpoint", "true");
((DynamicURIInboundEndpoint) endpoint).setEndpointURI(epURI);
}
catch (InitialisationException e)
{
throw new EndpointException(e);
}
return receiver;
}