1 22 package org.objectweb.petals.jbi.component.lifecycle.mock; 23 24 import java.util.HashMap ; 25 import java.util.Map ; 26 27 import javax.jbi.JBIException; 28 import javax.jbi.component.ServiceUnitManager; 29 import javax.jbi.management.DeploymentException; 30 31 36 public class ServiceUnitManagerMock implements ServiceUnitManager { 37 38 private Map <String , ServiceUnitMock> units = new HashMap <String , ServiceUnitMock>(); 39 40 public String deploy(String serviceUnitName, String serviceUnitRootPath) 41 throws DeploymentException { 42 ServiceUnitMock serviceUnit = new ServiceUnitMock(); 43 IdentificationMock identification = new IdentificationMock(); 44 identification.setName(serviceUnitName); 45 serviceUnit.setIdentification(identification); 46 units.put(serviceUnitName, serviceUnit); 47 return "Success"; 48 } 49 50 public void init(String serviceUnitName, String serviceUnitRootPath) 51 throws DeploymentException { 52 } 53 54 public void shutDown(String serviceUnitName) throws DeploymentException { 55 try { 56 units.get(serviceUnitName).shutDown(); 57 } catch (JBIException e) { 58 throw new DeploymentException(e); 59 } 60 } 61 62 public void start(String serviceUnitName) throws DeploymentException { 63 try { 64 units.get(serviceUnitName).start(); 65 } catch (JBIException e) { 66 throw new DeploymentException(e); 67 } 68 } 69 70 public void stop(String serviceUnitName) throws DeploymentException { 71 try { 72 units.get(serviceUnitName).stop(); 73 } catch (JBIException e) { 74 throw new DeploymentException(e); 75 } 76 } 77 78 public String undeploy(String serviceUnitName, String serviceUnitRootPath) 79 throws DeploymentException { 80 return null; 81 } 82 83 public Map <String , ServiceUnitMock> getUnits() { 84 return units; 85 } 86 87 } 88 | Popular Tags |