1 22 package org.jboss.system.microcontainer; 23 24 import javax.management.ObjectName ; 25 26 import org.jboss.system.Service; 27 import org.jboss.system.ServiceContext; 28 import org.jboss.system.ServiceController; 29 import org.jboss.system.ServiceMBean; 30 31 37 public class CreateDestroyLifecycleAction extends ServiceControllerContextAction 38 { 39 public void installAction(ServiceControllerContext context) throws Throwable 40 { 41 Service service = context.getServiceProxy(); 42 service.create(); 43 44 context.getServiceContext().state = ServiceContext.CREATED; 45 46 ObjectName objectName = context.getObjectName(); 47 ServiceController serviceController = context.getServiceController(); 48 serviceController.sendControllerNotification(ServiceMBean.CREATE_EVENT, objectName); 49 } 50 51 public void uninstallAction(ServiceControllerContext context) 52 { 53 try 54 { 55 Service service = context.getServiceProxy(); 56 service.destroy(); 57 58 context.getServiceContext().state = ServiceContext.DESTROYED; 59 60 ObjectName objectName = context.getObjectName(); 61 ServiceController serviceController = context.getServiceController(); 62 serviceController.sendControllerNotification(ServiceMBean.DESTROY_EVENT, objectName); 63 } 64 catch (Throwable t) 65 { 66 log.debug("Error during destroy for " + context.getObjectName(), t); 67 } 68 } 69 } 70 | Popular Tags |