public void undeploy(BeanContext beanContext) {
    Data data = (Data) beanContext.getContainerData();
    if (data == null) return;

    MBeanServer server = LocalMBeanServer.get();
    for (ObjectName objectName : data.jmxNames) {
      try {
        server.unregisterMBean(objectName);
      } catch (Exception e) {
        logger.error("Unable to unregister MBean " + objectName);
      }
    }

    beanContext.setContainerData(null);
  }
  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);
    }
  }
Пример #3
0
  @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 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);
  }
Пример #5
0
  @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 void deploy(BeanContext beanContext) throws OpenEJBException {
    Data data = new Data(beanContext);
    beanContext.setContainerData(data);

    beanContext.set(EJBContext.class, this.sessionContext);

    // 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("SingletonSessionBean", 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.add(objectName);
    } catch (Exception e) {
      logger.error("Unable to register MBean ", e);
    }

    try {
      final Context context = beanContext.getJndiEnc();
      context.bind("comp/EJBContext", sessionContext);
      context.bind("comp/WebServiceContext", webServiceContext);
      context.bind("comp/TimerService", new TimerServiceWrapper());
    } catch (NamingException e) {
      throw new OpenEJBException("Failed to bind EJBContext/WebServiceContext/TimerService", e);
    }
  }
  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);
    }
  }