/** * Returns the container specified by the given canonical object name * which is expected to be of the given type. * Never returns null. * * @param oid the canonical object name of the container * @param type the container type * @return the container * @throws IllegalStateException if the container is not registered */ @SuppressWarnings("unchecked") public static <T extends Container> T getContainer(String oid, Class<T> type) { return (T) getContainer(oid); }
/** * 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); }
/** * @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(); }
/** * 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)); }
@Override public StatefulContainer getContainer() { if (container == null) { container = (StatefulContainer) Ejb3Registry.findContainer(containerGuid); if (isClustered && container == null) container = (StatefulContainer) Ejb3Registry.getClusterContainer(containerClusterUid); } return container; }
/** * An incoming context from serialization. * * @param container * @param beanMO */ protected StatefulBeanContext(StatefulContainer container, MarshalledObject beanMO) { super(container); assert beanMO != null : "beanMO is null"; this.containerClusterUid = Ejb3Registry.clusterUid(container); this.containerGuid = Ejb3Registry.guid(container); this.isClustered = container.isClustered(); this.beanMO = beanMO; }
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { Reference ref = (Reference) obj; String containerGuid = (String) ref.get("containerGuid").getContent(); boolean isClustered = Boolean.getBoolean((String)ref.get("isClustered").getContent()); EJBContainer container = (EJBContainer)Ejb3Registry.getContainer(containerGuid); if (container == null && isClustered) { String containerClusterUid = (String) ref.get("containerClusterUid").getContent(); container = (EJBContainer)Ejb3Registry.getClusterContainer(containerClusterUid); } return container.peekContext().getEJBContext(); } }
for (Object obj : Ejb3Registry.getContainers())
/** * @see org.jboss.ejb3.session.SessionSpecContainer#lockedStart() */ @Override protected void lockedStart() throws Exception { super.lockedStart(); // org.jboss.ejb3.remoting.IsLocalInterceptor requires the container to be registered with Ejb3Registry Ejb3Registry.register(this); // pass on the control to our simple singleton container this.delegate.start(); }
try container = Ejb3Registry.findContainer(guid); if (container == null) container = Ejb3Registry.getClusterContainer(Ejb3Registry.clusterUid(oid, partitionName));
private void undeploy() { for (Container container : ejbContainers.values()) { Ejb3Registry.unregister(container); } }
/** * 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); }
public static final String guid(Container container) { return guid(container, vmid); }
protected SessionContext getDelegate() { if(delegate == null) { StatefulContainer container = (StatefulContainer)Ejb3Registry.getContainer(containerGuid); if (container == null && isClustered) container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid); delegate = new StatefulSessionContextDelegate(container.getCache().get(id, false)); } return delegate; }
/** * A brand new stateful session bean. * * @param container * @param bean */ protected StatefulBeanContext(StatefulContainer container, Object bean) { super(container, bean); this.containerClusterUid = Ejb3Registry.clusterUid(container); this.containerGuid = Ejb3Registry.guid(container); this.isClustered = container.isClustered(); this.id = new GUID(); }
for (Object obj : Ejb3Registry.getContainers())
Ejb3Registry.register(con);
public StatefulBeanContext getBeanContext() { if (beanContext == null) { StatefulContainer container = (StatefulContainer)Ejb3Registry.findContainer(containerGuid); if (isClustered && container == null) container = (StatefulContainer)Ejb3Registry.getClusterContainer(containerClusterUid); // We are willing to accept a context that has been marked as removed // as it can still hold nested children beanContext = container.getCache().get(oid, false); assert beanContext != null : "beanContext no longer in cache"; } return beanContext; } }
protected void lockedStart() throws Exception { super.lockedStart(); this.registerWithAopDispatcher(); // Obtain registrar JndiSessionRegistrarBase registrar = this.getJndiRegistrar(); // Bind all appropriate references/factories to Global JNDI for Client access, if a JNDI Registrar is present if (registrar != null) { String guid = Ejb3Registry.guid(this); registrar.bindEjb(this.getInitialContext(), this.getMetaData(), this.getClassloader(), this.getObjectName() .getCanonicalName(), guid, this.getAdvisor()); } else { log.debug("No " + JndiSessionRegistrarBase.class.getSimpleName() + " was found; bypassing binding of Proxies to " + this.getName() + " in Global JNDI."); } }
Container container = Ejb3Registry.getContainer(guid); return container.getEjbName();