FileDocCategorySizeDatePackage
JmxKernelAbstraction.javaAPI DocJBoss 4.2.16229Fri Jul 13 20:53:58 BST 2007org.jboss.ejb3

JmxKernelAbstraction

public class JmxKernelAbstraction extends JmxClientKernelAbstraction implements KernelAbstraction
Comment
author
Bill Burke
version
$Revision: 61201 $

Fields Summary
private static final Logger
log
private MBeanServer
server
private org.jboss.system.ServiceControllerMBean
serviceController
private org.jboss.deployment.DeploymentInfo
di
Constructors Summary
public JmxKernelAbstraction(org.jboss.deployment.DeploymentInfo di)


     
   
      super(di.getServer());
      this.server = di.getServer();
      serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
            di.getServer());
      this.di = di;
   
public JmxKernelAbstraction(MBeanServer server)

      super(server);
      serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
                                                                        server);
   
Methods Summary
private voidaddParentDependency(javax.management.ObjectName on)

      //di.mbeans.add(on);

      // this is done so that we can get dependency error messages.
      // and this is the only reason this is done.
      // if you don't put add to the top DI mbean list, then no dependency
      // error message is printed out if there is one.
      DeploymentInfo parent = di;
      while (parent.parent != null)
      {
         parent = parent.parent;
      }
      parent.mbeans.add(on);

   
public voidinstall(java.lang.String name, DependencyPolicy dependencies, java.lang.Object service)

      if (!(service instanceof ServiceMBeanSupport) && !(service instanceof DynamicMBean))
      {
         log.info("creating wrapper delegate for: " + service.getClass().getName());
         
         // create mbean delegate.
         if (service instanceof StatelessContainer)
         {
            service = new StatelessDelegateWrapper(service);
         }
         else if (service instanceof StatefulContainer)
         {
            service = new StatefulDelegateWrapper(service);
         }
         else if (service instanceof MDB)
         {
            service = new MdbDelegateWrapper(service);
         }
         else
         {
            service = new ServiceDelegateWrapper(service);
         }
      }
      JmxDependencyPolicy policy = (JmxDependencyPolicy)dependencies;
      try
      {
         log.info("installing MBean: " + name + " with dependencies:");
         for (Object obj : policy.getDependencies())
         {
            log.info("\t" + obj);
         }
         ObjectName on = new ObjectName(name);
         
         if(policy.getDependencies().contains(on))
            throw new IllegalStateException("circular dependencies detected");
         
         server.registerMBean(service, on);
         addParentDependency(on);

         serviceController.create(on, policy.getDependencies());
         serviceController.start(on);
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
   
public voidinstallMBean(javax.management.ObjectName on, DependencyPolicy dependencies, java.lang.Object service)

      JmxDependencyPolicy policy = (JmxDependencyPolicy)dependencies;
      try
      {
         server.registerMBean(service, on);
         addParentDependency(on);
         serviceController.create(on, policy.getDependencies());
         serviceController.start(on);
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
   
private voidremoveParentDependency(javax.management.ObjectName on)

      DeploymentInfo parent = di;
      while (parent.parent != null)
      {
         parent = parent.parent;
      }
      parent.mbeans.remove(on);
   
public voidsetMbeanServer(javax.management.MBeanServer server)

      this.server = server;
   
public voiduninstall(java.lang.String name)

      ObjectName on;
      try
      {
         on = new ObjectName(name);
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
      
      uninstallMBean(on);
   
public voiduninstallMBean(javax.management.ObjectName on)

      try
      {
         serviceController.stop(on);
         serviceController.destroy(on);
         serviceController.remove(on);
         removeParentDependency(on);
         if(server.isRegistered(on))
            server.unregisterMBean(on);
         else
            log.warn(on + " is not registered");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }