{
// Do not allow endpoints with null url property.
if (endpointUrl == null)
{
// Cannot add ''{0}'' with null url to the ''{1}''
ConfigurationException ex = new ConfigurationException();
ex.setMessage(NULL_ENDPOINT_URL, new Object[]{"Endpoint", "MessageBroker"});
throw ex;
}
String parsedEndpointURI = ChannelSettings.removeTokens(endpointUrl);
// first check the original URI
if (registeredEndpoints.containsKey(parsedEndpointURI))
{
ConfigurationException ce = new ConfigurationException();
ce.setMessage(URI_ALREADY_REGISTERED, new Object[] {id, parsedEndpointURI,
registeredEndpoints.get(parsedEndpointURI)});
throw ce;
}
// add the original URI to the registered endpoints map
registeredEndpoints.put(parsedEndpointURI, id);
// also need to check the URI without the context root
int nextSlash = parsedEndpointURI.indexOf('/', 1);
if (nextSlash > 0)
{
String parsedEndpointURI2 = parsedEndpointURI.substring(nextSlash);
if (registeredEndpoints.containsKey(parsedEndpointURI2))
{
ConfigurationException ce = new ConfigurationException();
ce.setMessage(URI_ALREADY_REGISTERED, new Object[] {
parsedEndpointURI2, id,
registeredEndpoints.get(parsedEndpointURI2) });
throw ce;
}
registeredEndpoints.put(parsedEndpointURI2, id);