/** * Removes a component. The {@link Component#shutdown} method will be called on the component. * Note that if the component was an external component that was connected several times then all * its connections will be terminated. * * @param subdomain the subdomain of the component's address. */ @Override public void removeComponent(String subdomain) { RoutableComponents components = null; if (routables == null || (components = routables.get(subdomain)) == null) { return; } List<Component> componentsToRemove = new ArrayList<>(components.getComponents()); for (Component component : componentsToRemove) { removeComponent(subdomain, component); } }
/** * Retrieves the <code>Component</code> which is mapped to the specified JID. The look up will * only be done on components that were registered with this JVM. That means that components * registered in other cluster nodes are not going to be considered. * * @param componentJID the jid mapped to the component. * @return the list of components with the specified id. */ private List<Component> getComponents(JID componentJID) { synchronized (routables) { if (componentJID.getNode() != null) { return Collections.emptyList(); } RoutableComponents routable = routables.get(componentJID.getDomain()); if (routable != null) { return routable.getComponents(); } else { // Search again for those JIDs whose domain include the server name but this // time remove the server name from the JID's domain String serverName = componentJID.getDomain(); int index = serverName.lastIndexOf("." + serverDomain); if (index > -1) { routable = routables.get(serverName.substring(0, index)); if (routable != null) { return routable.getComponents(); } } } return Collections.emptyList(); } }