/** * Returns the container specified by the given GUID. * Never returns null. * * @param guid the GUID * @return the container * @throws IllegalStateException if the container is not registered */ public static Container getContainer(String guid) { if(!hasContainer(guid)) throw new IllegalStateException("Container " + guid + " is not registered"); return containers.get(guid); }
/** * Reports the existance of a container. * * @param container the container to check * @return true if found, false otherwise */ public static boolean hasContainer(Container container) { return hasContainer(guid(container)); }
/** * Unregisters a container. * * @param container the container to unregister * @throws IllegalStateException if the container is not registered */ public static void unregister(Container container) { String guid = guid(container); if(!hasContainer(guid)) throw new IllegalStateException("Container " + guid + " + is not registered"); containers.remove(guid); if (container.isClustered()) clusterContainers.remove(clusterUid(container)); log.debug("Unregistered container " + guid); }
/** * Registers a container. * * @param container the container to register * @throws IllegalStateException if the container is already registered */ public static void register(Container container) { String guid = guid(container); if(hasContainer(guid)) throw new IllegalStateException("Container " + guid + " + is already registered"); containers.put(guid, container); if (container.isClustered()) clusterContainers.put(clusterUid(container), container); log.debug("Registered container " + guid); }
/** * @see org.jboss.ejb3.session.SessionSpecContainer#lockedStop() */ @Override protected void lockedStop() throws Exception { this.delegate.stop(); if (Ejb3Registry.hasContainer(this)) { Ejb3Registry.unregister(this); } super.lockedStop(); }