public synchronized void unregisterConnectionFactory(String uniqueName, boolean clustered)
throws Exception
{
log.trace("ConnectionFactory " + uniqueName + " being unregistered");
ServerConnectionFactoryEndpoint endpoint =
(ServerConnectionFactoryEndpoint)endpoints.remove(uniqueName);
if (endpoint == null)
{
throw new IllegalArgumentException("Cannot find endpoint with name " + uniqueName);
}
JNDIBindings jndiBindings = endpoint.getJNDIBindings();
if (jndiBindings != null)
{
List jndiNames = jndiBindings.getNames();
for(Iterator i = jndiNames.iterator(); i.hasNext(); )
{
String jndiName = (String)i.next();
initialContext.unbind(jndiName);
log.debug(jndiName + " unregistered");
}
}
if (trace) { log.trace("Removing delegate from delegates list with key=" + uniqueName + " at serverPeerID=" + this.serverPeer.getServerPeerID()); }
ConnectionFactoryDelegate delegate = (ConnectionFactoryDelegate)delegates.remove(uniqueName);
if (delegate == null)
{
throw new IllegalArgumentException("Cannot find factory with name " + uniqueName);
}
if (clustered)
{
setupReplicator();
// Remove from replicants
if (replicator != null)
{
//There may be no clustered post office deployed
if (!replicator.remove(CF_PREFIX + uniqueName))
{
throw new IllegalStateException("Cannot find replicant to remove: " +
CF_PREFIX + uniqueName);
}
}
}
Dispatcher.instance.unregisterTarget(endpoint.getID(), endpoint);
}