public SingletonContainer(Object id, SecurityService securityService) throws OpenEJBException { this.containerID = id; this.securityService = securityService; instanceManager = new SingletonInstanceManager(securityService); for (BeanContext beanContext : deploymentRegistry.values()) { beanContext.setContainer(this); } }
public void deploy(BeanContext beanContext) throws OpenEJBException { String id = (String) beanContext.getDeploymentID(); synchronized (this) { deploymentRegistry.put(id, beanContext); beanContext.setContainer(this); } EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null) { timerService.start(); } }
public void undeploy(BeanContext beanContext) { EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null) { timerService.stop(); } instanceManager.undeploy(beanContext); synchronized (this) { String id = (String) beanContext.getDeploymentID(); beanContext.setContainer(null); beanContext.setContainerData(null); deploymentRegistry.remove(id); } }
@Override public void undeploy(final BeanContext beanContext) throws OpenEJBException { synchronized (this) { deploymentsById.remove(beanContext.getDeploymentID()); beansByClass.remove(beanContext.getCmpImplClass()); try { final Field field = beanContext.getCmpImplClass().getField("deploymentInfo"); field.set(null, null); } catch (final Exception e) { // ignore } beanContext.setContainer(null); beanContext.setContainerData(null); } }
public StatelessContainer( Object id, SecurityService securityService, Duration accessTimeout, Duration closeTimeout, Pool.Builder poolBuilder, int callbackThreads) { this.containerID = id; this.securityService = securityService; instanceManager = new StatelessInstanceManager( securityService, accessTimeout, closeTimeout, poolBuilder, callbackThreads); for (BeanContext beanContext : deploymentRegistry.values()) { beanContext.setContainer(this); } }
public synchronized void deploy(BeanContext beanContext) throws OpenEJBException { Map<Method, MethodType> methods = getLifecycleMethodsOfInterface(beanContext); deploymentsById.put(beanContext.getDeploymentID(), beanContext); beanContext.setContainer(this); Data data = new Data(new Index<Method, MethodType>(methods)); beanContext.setContainerData(data); // Create stats interceptor StatsInterceptor stats = new StatsInterceptor(beanContext.getBeanClass()); beanContext.addSystemInterceptor(stats); MBeanServer server = LocalMBeanServer.get(); ObjectNameBuilder jmxName = new ObjectNameBuilder("openejb.management"); jmxName.set("J2EEServer", "openejb"); jmxName.set("J2EEApplication", null); jmxName.set("EJBModule", beanContext.getModuleID()); jmxName.set("StatelessSessionBean", beanContext.getEjbName()); jmxName.set("j2eeType", ""); jmxName.set("name", beanContext.getEjbName()); // register the invocation stats interceptor try { ObjectName objectName = jmxName.set("j2eeType", "Invocations").build(); server.registerMBean(new ManagedMBean(stats), objectName); data.jmxNames.add(objectName); } catch (Exception e) { logger.error("Unable to register MBean ", e); } try { final Context context = beanContext.getJndiEnc(); context.bind("comp/EJBContext", sessionContext); } catch (NamingException e) { throw new OpenEJBException("Failed to bind EJBContext", e); } beanContext.set(EJBContext.class, this.sessionContext); }
@Override public void deploy(final BeanContext beanContext) throws OpenEJBException { synchronized (this) { final Object deploymentId = beanContext.getDeploymentID(); cmpEngine.deploy(beanContext); beanContext.setContainerData(cmpEngine); beanContext.set(EJBContext.class, new EntityContext(securityService)); // try to set deploymentInfo static field on bean implementation class try { final Field field = beanContext.getCmpImplClass().getField("deploymentInfo"); field.set(null, beanContext); } catch (final Exception e) { // ignore } // add to indexes deploymentsById.put(deploymentId, beanContext); beansByClass.put(beanContext.getCmpImplClass(), beanContext); beanContext.setContainer(this); } }
public synchronized void undeploy(final BeanContext bean) throws OpenEJBException { Data data = (Data) bean.getContainerData(); MBeanServer server = LocalMBeanServer.get(); for (ObjectName objectName : data.jmxNames) { try { server.unregisterMBean(objectName); } catch (Exception e) { logger.error("Unable to unregister MBean " + objectName); } } deploymentsById.remove(bean.getDeploymentID()); bean.setContainer(null); bean.setContainerData(null); cache.removeAll( new CacheFilter<Instance>() { public boolean matches(Instance instance) { return bean == instance.beanContext; } }); }
public void undeploy(BeanContext beanContext) { ThreadContext threadContext = new ThreadContext(beanContext, null); ThreadContext old = ThreadContext.enter(threadContext); try { instanceManager.freeInstance(threadContext); } finally { ThreadContext.exit(old); } EjbTimerService timerService = beanContext.getEjbTimerService(); if (timerService != null) { timerService.stop(); } instanceManager.undeploy(beanContext); synchronized (this) { String id = (String) beanContext.getDeploymentID(); beanContext.setContainer(null); beanContext.setContainerData(null); deploymentRegistry.remove(id); } }