* In an OSGi world, this would be performed automatically by a ServiceTracker.
*
* @param endpoint the endpoint to unregister
*/
public void unregister(Endpoint endpoint, Map<String, ?> properties) {
InternalEndpoint wrapper;
if (endpoint instanceof InternalEndpoint) {
wrapper = (InternalEndpoint) endpoint;
if (wrapper != null) {
endpoint = wrappers.remove(wrapper);
if (endpoint != null) {
endpoints.remove(endpoint);
}
}
} else {
wrapper = endpoints.remove(endpoint);
if (wrapper != null) {
wrappers.remove(wrapper);
}
}
if (wrapper != null) {
wrapper.getChannel().close();
registry.unregister(wrapper, properties);
for (EndpointListener listener : nmr.getListenerRegistry().getListeners(EndpointListener.class)) {
listener.endpointUnregistered(wrapper);
}
}