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 StartStopLifecycleAction extends ServiceControllerContextAction 38 { 39 public void installAction(ServiceControllerContext context) throws Throwable 40 { 41 Service service = context.getServiceProxy(); 42 service.start(); 43 44 context.getServiceContext().state = ServiceContext.RUNNING; 45 46 ObjectName objectName = context.getObjectName(); 47 ServiceController serviceController = context.getServiceController(); 48 serviceController.sendControllerNotification(ServiceMBean.START_EVENT, objectName); 49 } 50 51 public void uninstallAction(ServiceControllerContext context) 52 { 53 try 54 { 55 Service service = context.getServiceProxy(); 56 service.stop(); 57 58 context.getServiceContext().state = ServiceContext.STOPPED; 59 60 ObjectName objectName = context.getObjectName(); 61 ServiceController serviceController = context.getServiceController(); 62 serviceController.sendControllerNotification(ServiceMBean.STOP_EVENT, objectName); 63 } 64 catch (Throwable t) 65 { 66 log.debug("Error during stop for " + context.getObjectName(), t); 67 } 68 } 69 } 70 | Popular Tags |