1 22 package org.objectweb.petals.engine.forward; 23 24 import java.io.File ; 25 import java.util.Map ; 26 import java.util.Properties ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 30 import javax.jbi.component.ComponentContext; 31 import javax.jbi.management.DeploymentException; 32 import javax.xml.namespace.QName ; 33 34 import org.objectweb.petals.component.common.basic.AbstractServiceUnitManager; 35 import org.objectweb.petals.component.common.util.ManagementMessageUtil; 36 import org.objectweb.petals.component.common.util.WSDLHelper; 37 import org.w3c.dom.Document ; 38 import org.w3c.dom.Node ; 39 40 41 55 public class PropertiesServiceUnitManager extends AbstractServiceUnitManager { 56 57 private Map <QName , Properties > serviceToPropertiesMap; 58 59 69 public PropertiesServiceUnitManager(ComponentContext context, Logger logger, 70 Map <QName ,Properties > serviceToPropertiesMap) throws DeploymentException { 71 super(context, logger); 72 this.serviceToPropertiesMap = serviceToPropertiesMap; 73 } 74 75 82 public void start(String serviceUnitName) throws DeploymentException { 83 logger.log(Level.FINE, "start serviceUnitName " + serviceUnitName); 84 String suRootPath = serviceUnitInstallationRootPath 85 .get(serviceUnitName); 86 Document serviceDesc = getServiceUnitWSDL(suRootPath); 87 if (serviceDesc != null) { 88 try { 89 activateEndpointsFromJBIDescription(serviceDesc, 90 serviceUnitName, suRootPath); 91 92 File jbiXmlFile = new File (suRootPath + File.separator 94 + "META-INF" + File.separator + "jbi.xml"); 95 Node servicesNode = getNode(jbiXmlFile, "services"); 96 Map <String , String > extensions = getExtensions(servicesNode); 97 start(serviceUnitName, suRootPath, serviceDesc, extensions); 98 } catch (Exception ex) { 99 logger.log(Level.SEVERE, FAILED_ACTIVATE_ENDPOINT + ex); 100 throw new DeploymentException(FAILED_ACTIVATE_ENDPOINT, ex); 101 } 102 } else { 103 throw new DeploymentException(INCOMPLETE_SERVICE_UNIT_PACKAGE); 104 } 105 } 106 107 119 protected void start(String serviceUnitName, String serviceUnitRootPath, 120 Document serviceDesc, Map <String , String > extensionMap) throws Exception { 121 Properties serviceProps = new Properties (); 123 serviceProps.putAll(extensionMap); 124 QName service = WSDLHelper.getServiceNameFromWSDLDocument(serviceDesc)[0]; 125 serviceToPropertiesMap.put(service, serviceProps); 126 } 127 128 129 136 public void stop(String serviceUnitName) throws DeploymentException { 137 try { 138 serviceUnitInstallationRootPath.remove(serviceUnitName); 139 deactivateEndpointsFromJBIDescription(serviceUnitName); 140 } catch (Exception e) { 141 throw new DeploymentException(FAILED_DEACTIVATE_ENDPOINT, e); 142 } 143 logger.log(Level.FINE, "stop serviceUnitName " + serviceUnitName); 144 } 145 146 152 public String undeploy(String serviceUnitName, String serviceUnitRootPath) 153 throws DeploymentException { 154 return ManagementMessageUtil.getComponentTaskResult(context 155 .getComponentName(), "undeploy", 156 ManagementMessageUtil.TASK_RESULT_SUCCESS); 157 } 158 159 174 public String deploy(String serviceUnitName, String serviceUnitRootPath) 175 throws DeploymentException { 176 String result = null; 177 if (serviceUnitMap.get(serviceUnitName) == null) { 178 File jbiXmlFile = new File (serviceUnitRootPath + File.separator 180 + "META-INF" + File.separator + "jbi.xml"); 181 Node servicesNode = getNode(jbiXmlFile, "services"); 182 Map <String , String > extensions = getExtensions(servicesNode); 183 deploy(serviceUnitName, serviceUnitRootPath, extensions); 184 185 logger.log(Level.FINE, "deploy serviceUnitName " 186 + serviceUnitName + "serviceUnitRootPath" 187 + serviceUnitRootPath); 188 result = ManagementMessageUtil.getComponentTaskResult(context 189 .getComponentName(), "deploy", 190 ManagementMessageUtil.TASK_RESULT_SUCCESS); 191 } else { 192 throw new DeploymentException(ERROR_DUPLICATE_SERVICE_UNIT); 193 } 194 return result; 195 } 196 197 protected void deploy(String serviceUnitName, String serviceUnitRootPath, 198 Map <String , String > arg0) { 199 } 201 202 @Override 203 protected void deploy(Map <String , String > arg0) { 204 } 206 207 } 208 | Popular Tags |