1 22 package org.jboss.system.microcontainer; 23 24 import javax.management.MBeanServer ; 25 import javax.management.ObjectName ; 26 27 import org.jboss.system.ServiceCreator; 28 import org.jboss.system.ServiceInstance; 29 import org.jboss.system.metadata.ServiceMetaData; 30 31 37 public class InstantiateAction extends ServiceControllerContextAction 38 { 39 public void installAction(ServiceControllerContext context) throws Throwable 40 { 41 MBeanServer server = context.getServiceController().getMBeanServer(); 42 ObjectName objectName = context.getObjectName(); 43 ServiceMetaData metaData = context.getServiceMetaData(); 44 Object mbean = context.getTarget(); 45 ServiceInstance instance = ServiceCreator.install(server, objectName, metaData, mbean); 46 context.setTarget(instance.getResource()); 47 } 48 49 public void uninstallAction(ServiceControllerContext context) 50 { 51 MBeanServer server = context.getServiceController().getMBeanServer(); 52 ObjectName objectName = context.getObjectName(); 53 ServiceCreator.uninstall(server, objectName); 54 ServiceMetaData metaData = context.getServiceMetaData(); 55 if (metaData != null) 56 context.setTarget(null); 57 } 58 } 59 | Popular Tags |