1 22 package org.objectweb.petals.jbi.component.lifecycle; 23 24 import javax.jbi.JBIException; 25 import javax.jbi.component.ServiceUnitManager; 26 27 import org.objectweb.petals.jbi.component.event.StateChangeFailedEvent; 28 import org.objectweb.petals.jbi.component.event.StateChangedEvent; 29 import org.objectweb.petals.jbi.management.service.LifeCycleManagerService; 30 import org.objectweb.petals.tools.jbicommon.descriptor.ServiceUnit; 31 import org.objectweb.petals.util.LoggingUtil; 32 33 39 public class ServiceUnitLifeCycle extends LifeCycleAbstract { 40 41 private LifeCycleManagerService managerService; 42 43 private ServiceUnit serviceUnit; 44 45 private String suName; 46 47 private String serviceUnitRootPath; 48 49 public ServiceUnitLifeCycle(ServiceUnit serviceUnit, 50 LifeCycleManagerService managerService, String serviceUnitRootPath, 51 LoggingUtil log) { 52 super(null, log); 53 this.managerService = managerService; 54 this.serviceUnit = serviceUnit; 55 this.serviceUnitRootPath = serviceUnitRootPath; 56 this.suName = serviceUnit.getIdentification().getName(); 57 } 58 59 65 public ServiceUnitManager getServiceUnitManager() { 66 ServiceUnitManager result = null; 67 ComponentLifeCycle clc = managerService.getComponentByName(serviceUnit 68 .getTargetComponentName()); 69 if (clc != null) { 70 result = clc.getComponent().getServiceUnitManager(); 71 } 72 return result; 73 } 74 75 public String getServiceUnitRootPath() { 76 return serviceUnitRootPath; 77 } 78 79 public String getSuName() { 80 return suName; 81 } 82 83 86 @Override 87 public synchronized void stateChanged(StateChangedEvent event) { 88 89 } 90 91 94 @Override 95 public synchronized void stateChangeFailed(StateChangeFailedEvent event) { 96 97 } 98 99 @Override 100 public void doInit() throws JBIException { 101 getServiceUnitManager().init(suName, serviceUnitRootPath); 102 } 103 104 @Override 105 public void doStart() throws JBIException { 106 getServiceUnitManager().start(suName); 107 } 108 109 @Override 110 public void doStop() throws JBIException { 111 getServiceUnitManager().stop(suName); 112 } 113 114 @Override 115 public void doShutdown() throws JBIException { 116 getServiceUnitManager().shutDown(suName); 117 } 118 119 } 120 | Popular Tags |