[jboss-svn-commits] JBL Code SVN: r20798 - in labs/jbossesb/workspace/jimma/product/rosetta: src/org/jboss/internal/soa/esb/webservice and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 26 08:38:16 EDT 2008


Author: jim.ma
Date: 2008-06-26 08:38:16 -0400 (Thu, 26 Jun 2008)
New Revision: 20798

Added:
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
Removed:
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java
Modified:
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGenerator.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/app-xml.template
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java
   labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java
   labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGeneratorUnitTest.java
   labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/webservice_test.esb
Log:
* Enable the JBossWSDeploymentGenerator generate mutiple service
* Generate service contract in ESBServiceContractGenerator instead of ServiceContractPublisher


Deleted: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/publish/ServiceContractPublisher.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.internal.soa.esb.publish;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-import javax.wsdl.Binding;
-import javax.wsdl.BindingFault;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Part;
-import javax.wsdl.PortType;
-import javax.wsdl.Types;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.xml.namespace.QName;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.dom.YADOMUtil;
-import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
-import org.jboss.soa.esb.util.ClassUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import com.ibm.wsdl.extensions.schema.SchemaImpl;
-import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
-import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
-
-public class ServiceContractPublisher implements ContractPublisher {
-	private final QName XSD_QN = new QName("http://www.w3.org/2001/XMLSchema", "schema");
-	private String wsdl;
-	private Definition def = null;
-	private int nsSuffixCounter = 1;
-	private Service svcConfig;
- 
-	public ServiceContractPublisher(Service serviceConfig) {
-		svcConfig = serviceConfig;
-	}
-	
-	public void generateWSDL(Service serviceConfig) throws ConfigurationException {
-		String targetNamespace = "http://soa.jboss.org/" + serviceConfig.getCategory().toLowerCase();
-		String serviceName = serviceConfig.getName();
-		try {
-			def = WSDLFactory.newInstance().newDefinition();
-		} catch (WSDLException e1) {
-			e1.printStackTrace();
-		}
-		def.setTargetNamespace(targetNamespace);
-		def.addNamespace("tns", targetNamespace);
-		def.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
-		// add types
-		Types types = def.createTypes();
-		def.setTypes(types);
-
-		Message reqMessage = null;
-		Message resMessage = null;
-		Message faultMessage = null;
-
-		String inXsd = serviceConfig.getActions().getInXsd();
-		String outXsd = serviceConfig.getActions().getOutXsd();
-		String faultXsd = serviceConfig.getActions().getFaultXsd();
-
-		if (inXsd != null) {
-			try {
-				Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(inXsd, getClass()), false, false);
-				if (doc != null) {
-					reqMessage = addMessage(doc.getDocumentElement(),
-							serviceName + "Req", "in");
-				}
-			} catch (IOException e) {
-				throw new ConfigurationException("File defined in inXsd attribute '" + serviceConfig.getActions().getInXsd() + "' not found in classpath.", e);
-			} catch (SAXException e) {
-				throw new ConfigurationException("invalid inXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
-			} 
-		
-
-		}
-
-		if (outXsd != null) {
-			try {
-				Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(outXsd, getClass()), false, false);
-				if (doc != null) {
-					resMessage = addMessage(doc.getDocumentElement(),
-							serviceName + "Res", "out");
-				}
-			} catch (IOException e) {
-				throw new ConfigurationException("File defined in outXsd attribute '" + serviceConfig.getActions().getOutXsd() + "' not found in classpath.", e);
-			} catch (SAXException e) {
-				throw new ConfigurationException("Invalid outXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
-			} 
-
-		}
-
-		if (faultXsd != null) {
-			try {
-				Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(faultXsd, getClass()), false,
-						false);
-				if (doc != null) {
-					faultMessage = addMessage(doc.getDocumentElement(),
-							serviceName + "fault", "fault");
-				}
-			} catch (IOException e) {
-				throw new ConfigurationException("File defined in faultXsd attribute '" + serviceConfig.getActions().getFaultXsd() + "' not found in classpath.", e);
-			} catch (SAXException e) {
-				throw new ConfigurationException("Invalid faultXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
-			} 
-
-		}
-
-		PortType portType = addPortType(serviceName, reqMessage, resMessage,
-				faultMessage);
-		Binding binding = addBinding(serviceName, portType);
-		addService(serviceName, binding);
-		StringWriter sw = new java.io.StringWriter();
-		try {
-			WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sw);
-		} catch (WSDLException e) {
-			new ConfigurationException("Failed to generate wsdl for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
-		}
-		wsdl = sw.toString();
-	}
-
-	public ContractInfo getContractInfo(EPR epr) {
-		return new ContractInfo("text/xml", wsdl);
-	}
-
-	private void addSchema(Types types, Element xsdElement) {
-		SchemaImpl schemaImpl = new SchemaImpl();
-		schemaImpl.setElement(xsdElement);
-		schemaImpl.setElementType(XSD_QN);
-		types.addExtensibilityElement(schemaImpl);
-
-	}
-
-	private Message addMessage(Element element, String msgName, String partName) {
-		String schemaNs = YADOMUtil
-				.getAttribute(element, "targetNamespace", "");
-		addSchema(def.getTypes(), element);
-		if (def.getNamespace(schemaNs) == null) {
-			def.addNamespace("ns" + nsSuffixCounter, schemaNs);
-			nsSuffixCounter++;
-		}
-		// add request message
-		Node node = YADOMUtil.getNode(element, "/schema/element");
-		Message msg = def.createMessage();
-		msg.setQName(new QName(def.getTargetNamespace(), msgName));
-		msg.setUndefined(false);
-		Part part = def.createPart();
-		part.setName(partName);
-		part.setElementName(new QName(schemaNs, YADOMUtil.getAttribute(
-				(Element) node, "name", "")));
-		msg.addPart(part);
-		def.addMessage(msg);
-		return msg;
-	}
-
-	private PortType addPortType(String serviceName, Message inMessage,
-			Message outMessage, Message faultMessage) {
-		// add port type
-		PortType portType = def.createPortType();
-		portType.setQName(new QName(def.getTargetNamespace(), serviceName
-				+ "PortType"));
-		Operation op = def.createOperation();
-		op.setUndefined(false);
-		op.setName(serviceName);
-		if (inMessage != null) {
-			Input in = def.createInput();
-			in.setMessage(inMessage);
-			in.setName(inMessage.getQName().getLocalPart());
-			op.setInput(in);
-		}
-		if (outMessage != null) {
-			Output out = def.createOutput();
-			out.setMessage(outMessage);
-			out.setName(outMessage.getQName().getLocalPart());
-			op.setOutput(out);
-		}
-
-		if (faultMessage != null) {
-			Fault fault = def.createFault();
-			fault.setMessage(faultMessage);
-			fault.setName(faultMessage.getQName().getLocalPart());
-			op.addFault(fault);
-		}
-		portType.addOperation(op);
-		portType.setUndefined(false);
-		def.addPortType(portType);
-		return portType;
-	}
-
-	private Binding addBinding(String serviceName, PortType portType) {
-		// add binding
-		Binding binding = def.createBinding();
-		binding.setUndefined(false);
-		binding.setPortType(portType);
-		binding.setQName(new QName(def.getTargetNamespace(), serviceName
-				+ "Binding"));
-		SOAPBindingImpl soapBinding = new SOAPBindingImpl();
-		soapBinding.setStyle("document");
-		soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
-		binding.addExtensibilityElement(soapBinding);
-
-		BindingOperation bop = def.createBindingOperation();
-
-		bop.setName(serviceName);
-		Operation op = (Operation) portType.getOperations().get(0);
-		bop.setOperation(op);
-		if (op.getInput() != null) {
-			BindingInput binput = def.createBindingInput();
-			bop.setBindingInput(binput);
-		}
-		if (op.getOutput() != null) {
-			BindingOutput boutput = def.createBindingOutput();
-			bop.setBindingOutput(boutput);
-		}
-		if (op.getFaults().size() != 0) {
-			BindingFault bfault = def.createBindingFault();
-			Fault fault = (Fault) op.getFaults().values().iterator().next();
-			bfault.setName(fault.getName());
-			bop.addBindingFault(bfault);
-		}
-		binding.addBindingOperation(bop);
-		def.addBinding(binding);
-		return binding;
-
-	}
-
-	private void addService(String serviceName, Binding binding) {
-		// create service
-		javax.wsdl.Service service = def.createService();
-		service.setQName(new QName(def.getTargetNamespace(), serviceName
-				+ "Service"));
-		javax.wsdl.Port port = def.createPort();
-		port.setBinding(binding);
-		port.setName(serviceName + "Port");
-		SOAPAddressImpl soapAddress = new SOAPAddressImpl();
-		soapAddress.setLocationURI("http://change_this_URI");
-		port.addExtensibilityElement(soapAddress);
-		service.addPort(port);
-		def.addService(service);
-	}
-	
-	public Service getServiceConfig() {
-		return svcConfig;
-	}
-	
-	public String getWSDL() {
-		return wsdl;
-	}
-
-}

Added: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	                        (rev 0)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.webservice;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Message;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Part;
+import javax.wsdl.PortType;
+import javax.wsdl.Types;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.xml.namespace.QName;
+
+import org.jboss.internal.soa.esb.publish.ContractInfo;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import com.ibm.wsdl.extensions.schema.SchemaImpl;
+import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
+import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
+
+public class ESBContractGenerator {
+	private final QName XSD_QN = new QName("http://www.w3.org/2001/XMLSchema", "schema");
+	private String wsdl;
+	private Definition def = null;
+	private int nsSuffixCounter = 1;
+	private Service svcConfig;
+ 
+	public ESBContractGenerator(Service serviceConfig) {
+		svcConfig = serviceConfig;
+	}
+	
+	public void generateWSDL(Service serviceConfig) throws ConfigurationException {
+		String targetNamespace = "http://soa.jboss.org/" + serviceConfig.getCategory().toLowerCase();
+		String serviceName = serviceConfig.getName();
+		try {
+			def = WSDLFactory.newInstance().newDefinition();
+		} catch (WSDLException e1) {
+			e1.printStackTrace();
+		}
+		def.setTargetNamespace(targetNamespace);
+		def.addNamespace("tns", targetNamespace);
+		def.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+		// add types
+		Types types = def.createTypes();
+		def.setTypes(types);
+
+		Message reqMessage = null;
+		Message resMessage = null;
+		Message faultMessage = null;
+
+		String inXsd = serviceConfig.getActions().getInXsd();
+		String outXsd = serviceConfig.getActions().getOutXsd();
+		String faultXsd = serviceConfig.getActions().getFaultXsd();
+
+		if (inXsd != null) {
+			try {
+				Document doc = YADOMUtil.parseStream(ClassUtil
+						.getResourceAsStream(inXsd, getClass()), false, false);
+				if (doc != null) {
+					reqMessage = addMessage(doc.getDocumentElement(),
+							serviceName + "Req", "in");
+				}
+			} catch (IOException e) {
+				throw new ConfigurationException("File defined in inXsd attribute '" + serviceConfig.getActions().getInXsd() + "' not found in classpath.", e);
+			} catch (SAXException e) {
+				throw new ConfigurationException("invalid inXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+			} 
+		
+
+		}
+
+		if (outXsd != null) {
+			try {
+				Document doc = YADOMUtil.parseStream(ClassUtil
+						.getResourceAsStream(outXsd, getClass()), false, false);
+				if (doc != null) {
+					resMessage = addMessage(doc.getDocumentElement(),
+							serviceName + "Res", "out");
+				}
+			} catch (IOException e) {
+				throw new ConfigurationException("File defined in outXsd attribute '" + serviceConfig.getActions().getOutXsd() + "' not found in classpath.", e);
+			} catch (SAXException e) {
+				throw new ConfigurationException("Invalid outXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+			} 
+
+		}
+
+		if (faultXsd != null) {
+			try {
+				Document doc = YADOMUtil.parseStream(ClassUtil
+						.getResourceAsStream(faultXsd, getClass()), false,
+						false);
+				if (doc != null) {
+					faultMessage = addMessage(doc.getDocumentElement(),
+							serviceName + "fault", "fault");
+				}
+			} catch (IOException e) {
+				throw new ConfigurationException("File defined in faultXsd attribute '" + serviceConfig.getActions().getFaultXsd() + "' not found in classpath.", e);
+			} catch (SAXException e) {
+				throw new ConfigurationException("Invalid faultXsd file for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+			} 
+
+		}
+
+		PortType portType = addPortType(serviceName, reqMessage, resMessage,
+				faultMessage);
+		Binding binding = addBinding(serviceName, portType);
+		addService(serviceName, binding);
+		StringWriter sw = new java.io.StringWriter();
+		try {
+			WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sw);
+		} catch (WSDLException e) {
+			new ConfigurationException("Failed to generate wsdl for service:" + serviceConfig.getCategory() + "/" + serviceConfig.getName() , e);
+		}
+		wsdl = sw.toString();
+	}
+
+	public ContractInfo getContractInfo(EPR epr) {
+		
+		return new ContractInfo("text/html", wsdl);
+	}
+
+	private void addSchema(Types types, Element xsdElement) {
+		SchemaImpl schemaImpl = new SchemaImpl();
+		schemaImpl.setElement(xsdElement);
+		schemaImpl.setElementType(XSD_QN);
+		types.addExtensibilityElement(schemaImpl);
+
+	}
+
+	private Message addMessage(Element element, String msgName, String partName) {
+		String schemaNs = YADOMUtil
+				.getAttribute(element, "targetNamespace", "");
+		addSchema(def.getTypes(), element);
+		if (def.getNamespace(schemaNs) == null) {
+			def.addNamespace("ns" + nsSuffixCounter, schemaNs);
+			nsSuffixCounter++;
+		}
+		// add request message
+		Node node = YADOMUtil.getNode(element, "/schema/element");
+		Message msg = def.createMessage();
+		msg.setQName(new QName(def.getTargetNamespace(), msgName));
+		msg.setUndefined(false);
+		Part part = def.createPart();
+		part.setName(partName);
+		part.setElementName(new QName(schemaNs, YADOMUtil.getAttribute(
+				(Element) node, "name", "")));
+		msg.addPart(part);
+		def.addMessage(msg);
+		return msg;
+	}
+
+	private PortType addPortType(String serviceName, Message inMessage,
+			Message outMessage, Message faultMessage) {
+		// add port type
+		PortType portType = def.createPortType();
+		portType.setQName(new QName(def.getTargetNamespace(), serviceName
+				+ "PortType"));
+		Operation op = def.createOperation();
+		op.setUndefined(false);
+		op.setName(serviceName);
+		if (inMessage != null) {
+			Input in = def.createInput();
+			in.setMessage(inMessage);
+			in.setName(inMessage.getQName().getLocalPart());
+			op.setInput(in);
+		}
+		if (outMessage != null) {
+			Output out = def.createOutput();
+			out.setMessage(outMessage);
+			out.setName(outMessage.getQName().getLocalPart());
+			op.setOutput(out);
+		}
+
+		if (faultMessage != null) {
+			Fault fault = def.createFault();
+			fault.setMessage(faultMessage);
+			fault.setName(faultMessage.getQName().getLocalPart());
+			op.addFault(fault);
+		}
+		portType.addOperation(op);
+		portType.setUndefined(false);
+		def.addPortType(portType);
+		return portType;
+	}
+
+	private Binding addBinding(String serviceName, PortType portType) {
+		// add binding
+		Binding binding = def.createBinding();
+		binding.setUndefined(false);
+		binding.setPortType(portType);
+		binding.setQName(new QName(def.getTargetNamespace(), serviceName
+				+ "Binding"));
+		SOAPBindingImpl soapBinding = new SOAPBindingImpl();
+		soapBinding.setStyle("document");
+		soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+		binding.addExtensibilityElement(soapBinding);
+
+		BindingOperation bop = def.createBindingOperation();
+
+		bop.setName(serviceName);
+		Operation op = (Operation) portType.getOperations().get(0);
+		bop.setOperation(op);
+		if (op.getInput() != null) {
+			BindingInput binput = def.createBindingInput();
+			bop.setBindingInput(binput);
+		}
+		if (op.getOutput() != null) {
+			BindingOutput boutput = def.createBindingOutput();
+			bop.setBindingOutput(boutput);
+		}
+		if (op.getFaults().size() != 0) {
+			BindingFault bfault = def.createBindingFault();
+			Fault fault = (Fault) op.getFaults().values().iterator().next();
+			bfault.setName(fault.getName());
+			bop.addBindingFault(bfault);
+		}
+		binding.addBindingOperation(bop);
+		def.addBinding(binding);
+		return binding;
+
+	}
+
+	private void addService(String serviceName, Binding binding) {
+		// create service
+		javax.wsdl.Service service = def.createService();
+		service.setQName(new QName(def.getTargetNamespace(), serviceName
+				+ "Service"));
+		javax.wsdl.Port port = def.createPort();
+		port.setBinding(binding);
+		port.setName(serviceName + "Port");
+		SOAPAddressImpl soapAddress = new SOAPAddressImpl();
+		soapAddress.setLocationURI("http://change_this_URI");
+		port.addExtensibilityElement(soapAddress);
+		service.addPort(port);
+		def.addService(service);
+	}
+	
+	public Service getServiceConfig() {
+		return svcConfig;
+	}
+	
+	public String getWSDL() {
+		return wsdl;
+	}
+
+}

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBServiceEndpointInfo.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -91,6 +91,9 @@
 	}
 	
 	public String getTargetNamesapce() {
+		if (targetNS == null) {
+			return "http://soa.jboss.org/" + this.svcCat.toLowerCase();
+		} 
 		return targetNS;
 	}
 	
@@ -98,6 +101,15 @@
 		return svcCat.toLowerCase() + "-" + svcName.toLowerCase() + ".wsdl";
 	}
 	
+	public String getWarName() {
+		return svcCat.toLowerCase() + "-" + svcName.toLowerCase() + ".war";
+	}
+	
+	public String getWarContextRoot() {
+		return svcCat.toLowerCase() + "-" + svcName.toLowerCase();
+	}
+	
+	
 	public String getWSDLServiceName() {
 		return svcName + "Service";
 	}

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JAXWSProviderClassGenerator.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -38,7 +38,6 @@
 
 import org.antlr.stringtemplate.StringTemplate;
 import org.apache.commons.io.IOUtils;
-import org.jboss.soa.esb.message.Message;
 import org.jboss.soa.esb.util.ClassUtil;
 
 public class JAXWSProviderClassGenerator {

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGenerator.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGenerator.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGenerator.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -25,8 +25,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.ArrayList;
+import java.util.List;
 
+import javassist.CannotCompileException;
 import javassist.CtClass;
 
 import org.antlr.stringtemplate.StringTemplate;
@@ -35,32 +37,34 @@
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.util.ClassUtil;
-import org.jboss.system.server.ServerConfig;
 import org.jboss.system.server.ServerConfigLocator;
 import org.jboss.util.file.JarUtils;
 
 public class JBossWSDeploymentGenerator {
 	private Logger logger = Logger.getLogger(getClass());
-	private String warName;
-	protected CopyOnWriteArrayList<File> warFileList = new CopyOnWriteArrayList<File>();
-	protected CopyOnWriteArrayList<File> earFileList = new CopyOnWriteArrayList<File>();
-	public String tmpDir = System.getProperty("java.io.tmpdir");
-	protected ESBServiceEndpointInfo endpointInfo;
+
+	private final String earName = "esb-generated";
+	protected List<File> warFileList = new ArrayList<File>();
+	protected List<File> earFileList = new ArrayList<File>();
+	protected List<ESBServiceEndpointInfo> endpointInfos;
 	protected File tempDeployDir = null;
-    
-	public JBossWSDeploymentGenerator(ESBServiceEndpointInfo endpoint) {
-		endpointInfo = endpoint;
-		warName = endpoint.getDeploymentInfo().shortName.replace('.', '_')
-				+ ".war";
-		ServerConfig config = ServerConfigLocator.locate();
-		tempDeployDir = config.getServerTempDeployDir();
+
+	public JBossWSDeploymentGenerator(List<ESBServiceEndpointInfo> endpoints) {
+		this(endpoints, ServerConfigLocator.locate().getServerTempDeployDir());
 	}
+	
+	public JBossWSDeploymentGenerator(List<ESBServiceEndpointInfo> endpoints, File tmpDir) {
+		endpointInfos = endpoints;;
+		tempDeployDir = tmpDir;
+	}
+	
 
-	private File generateEar() throws Exception {
+	private File generateEar() throws WebServicePublishException {
+		File earFile = null;
 		try {
 			addFileToEar(generateEarAppXml());
-			File earTmp = File.createTempFile("tmp", endpointInfo.getEndpointName()
-					+ ".ear", tempDeployDir);
+			File earTmp = File.createTempFile("tmp", earName + ".ear",
+					tempDeployDir);
 			earTmp.delete();
 			earTmp.mkdirs();
 			File earDir = new File(earTmp.getPath() + File.separator + "contents");
@@ -76,33 +80,31 @@
 
 				FileUtils.copyFileToDirectory(file, dir);
 			}
-
-			File warFile = this.generateWar();
-			FileUtils.copyFileToDirectory(warFile, earDir);
-			String earName = endpointInfo.getServiceCategory().toLowerCase()
-					+ "-" + endpointInfo.getServiceName().toLowerCase()
-					+ ".ear";
-			File earFile = new File(earTmp + File.separator + earName);
+			for (ESBServiceEndpointInfo epInfo : endpointInfos) {
+				File warFile = generateWar(epInfo);
+				FileUtils.copyFileToDirectory(warFile, earDir);
+			}
+			String earFileName = earName + ".ear";
+			earFile = new File(earTmp + File.separator + earFileName);
 			earFile.createNewFile();
 			FileOutputStream fout = new FileOutputStream(earFile);
 			JarUtils.jar(fout, earDir.listFiles());
 			fout.close();
-			logger.log(Level.DEBUG, "Generated ear file for Endpoint "
-					+ endpointInfo.getEndpointName());
-			return earFile;
-		} catch (Exception e) {
-			throw e;
+		} catch (IOException e) {
+			throw new WebServicePublishException("Failed to generate ear file for publishing the esb service", e);
 		}
+		
+		return earFile;
 
 	}
 
-	private File generateWar() throws Exception {
+	private File generateWar(ESBServiceEndpointInfo endpointInfo) throws WebServicePublishException {
+		File warFile = null;
 		try {
-			addFileToWar(generateWebXml());
-			addFileToWar(generateWSDLFile());
-			addFileToWar(generateJbossWebXml());
-			File warTmp = File.createTempFile("tmp", endpointInfo.getEndpointName()
-					+ ".war", tempDeployDir);
+			addFileToWar(generateWebXml(endpointInfo));
+			addFileToWar(generateWSDLFile(endpointInfo));
+			addFileToWar(generateJbossWebXml(endpointInfo));
+			File warTmp = File.createTempFile("tmp", endpointInfo.getWarName(), tempDeployDir);
 			warTmp.delete();
 			warTmp.mkdirs();
 			File warDir = new File(warTmp.getPath() + File.separator + "contents");
@@ -117,72 +119,76 @@
 				}
 
 				FileUtils.copyFileToDirectory(file, dir);
+				JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
+				CtClass providerClass = generator.generate(endpointInfo);
+				providerClass.writeFile(warDir.getCanonicalPath());
+				warFile = new File(warTmp + File.separator + endpointInfo.getWarName());
+				warFile.createNewFile();
+				FileOutputStream fout = new FileOutputStream(warFile);
+				JarUtils.jar(fout, warDir.listFiles());
+				fout.close();
+				logger.log(Level.DEBUG, "Generated webserivce war file for Endpoint "
+						+ endpointInfo.getEndpointName());
 			}
-
-			JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
-			CtClass providerClass = generator.generate(endpointInfo);
-			providerClass.writeFile(warDir.getCanonicalPath());
-			File warFile = new File(warTmp + File.separator + warName);
-			warFile.createNewFile();
-			FileOutputStream fout = new FileOutputStream(warFile);
-			JarUtils.jar(fout, warDir.listFiles());
-			fout.close();
-			logger.log(Level.DEBUG,
-					"Generated webserivce war file for Endpoint "
-							+ endpointInfo.getEndpointName());
-			return warFile;
-		} catch (Exception e) {
-			throw e;
+		} catch (IOException e) {
+			throw new WebServicePublishException("Failed to generate webservice war file", e);
+		} catch (CannotCompileException e) {
+			throw new WebServicePublishException("Failed to generate Jaxws provider class", e);
 		}
-
+		return warFile;
 	}
 
 	// Directly deploy the generated webservice war file in esb server
 	public void deployWar(File esbFile) throws WebServicePublishException {
-		File wsWar;
-		try {
-			wsWar = generateWar();
-		} catch (Exception e1) {
-			throw new WebServicePublishException(
-					"Failed to generate war file for Endpoint "
-							+ endpointInfo.getEndpointName(), e1);
-		}
 		File deployDir = esbFile.getParentFile();
+		for (ESBServiceEndpointInfo endpointInfo : this.endpointInfos) {
+			File wsWar;
+			try {
+				wsWar = generateWar(endpointInfo);
+			} catch (Exception e1) {
+				throw new WebServicePublishException(
+						"Failed to generate war file for Endpoint "
+								+ endpointInfo.getEndpointName(), e1);
+			}
 
-		try {
-			FileUtils.copyFileToDirectory(wsWar, deployDir);
-		} catch (Exception e) {
-			throw new WebServicePublishException(
-					"Failed to add war file to esb service "
-							+ esbFile.getName(), e);
+			try {
+				FileUtils.copyFileToDirectory(wsWar, deployDir);
+			} catch (Exception e) {
+				throw new WebServicePublishException(
+						"Failed to add war file to esb service "
+								+ esbFile.getName(), e);
+			}
 		}
 
-		logger.log(Level.DEBUG, "Deployed webservice war for esb service "
+		logger.log(Level.DEBUG, "Deployed generated webservice war for esb service "
 				+ esbFile.getName());
 
 	}
 
 	// package the web serivice war as a subdeployment of ESB archive
-	public void injectWarToESBArchive(File esbFile)
-			throws WebServicePublishException {
-		File warFile;
-		try {
-			warFile = generateWar();
-		} catch (Exception e1) {
-			e1.printStackTrace();
-			throw new WebServicePublishException(
-					"Failed to generate war file for Endpoint "
-							+ endpointInfo.getEndpointName(), e1);
+	public void injectWarToESBArchive(File esbFile) throws WebServicePublishException {
+		List<File> warFiles = new ArrayList<File>();
+
+		for (ESBServiceEndpointInfo endpoint : endpointInfos) {
+			try {
+				warFiles.add(generateWar(endpoint));
+			} catch (Exception e1) {
+				throw new WebServicePublishException(
+						"Failed to generate war file for Endpoint "
+								+ endpoint.getEndpointName(), e1);
+			}
 		}
-
 		if (esbFile.exists() && esbFile.isFile()) {
 			try {
 				FileInputStream fin = new FileInputStream(esbFile);
-				File tmpDir = File.createTempFile("tmp", esbFile.getName(), tempDeployDir);
+				File tmpDir = File.createTempFile("tmp", esbFile.getName(),
+						tempDeployDir);
 				tmpDir.delete();
 				tmpDir.mkdirs();
 				JarUtils.unjar(fin, tmpDir);
-				FileUtils.copyFileToDirectory(warFile, tmpDir);
+				for (File warFile : warFiles) {
+					FileUtils.copyFileToDirectory(warFile, tmpDir);
+				}
 				fin.close();
 
 				esbFile.delete();
@@ -191,13 +197,16 @@
 				JarUtils.jar(fout, tmpDir.listFiles());
 				fout.close();
 			} catch (Exception e) {
+				
 				throw new WebServicePublishException(
 						"Failed to package the ear file in esb service archive "
 								+ esbFile.getName(), e);
 			}
 		} else if (esbFile.exists() && esbFile.isDirectory()) {
 			try {
-				FileUtils.copyFileToDirectory(warFile, esbFile);
+				for (File warFile : warFiles) {
+					FileUtils.copyFileToDirectory(warFile, esbFile);
+				}
 			} catch (Exception e) {
 				throw new WebServicePublishException(
 						"Failed to add war file to esb service "
@@ -205,8 +214,7 @@
 			}
 
 		}
-		logger.log(Level.DEBUG,
-				"Packaged webservice deployment .war into esb service archive "
+		logger.log(Level.DEBUG, "Packaged webservice deployment .war into esb service archive "
 						+ esbFile.getName());
 
 	}
@@ -219,16 +227,15 @@
 		try {
 			earFile = generateEar();
 		} catch (Exception e1) {
-			e1.printStackTrace();
 			throw new WebServicePublishException(
-					"Failed to Generate ear file for Endpoint "
-							+ endpointInfo.getEndpointName(), e1);
+					"Failed to Generate ear file for esb service " +  esbFile.getName(), e1);
 		}
 
 		if (esbFile.exists() && esbFile.isFile()) {
 			try {
 				FileInputStream fin = new FileInputStream(esbFile);
-				File tmpDir = File.createTempFile("tmp", esbFile.getName(), tempDeployDir);
+				File tmpDir = File.createTempFile("tmp", esbFile.getName(),
+						tempDeployDir);
 				tmpDir.delete();
 				tmpDir.mkdirs();
 				JarUtils.unjar(fin, tmpDir);
@@ -269,7 +276,8 @@
 		earFileList.add(file);
 	}
 
-	private File generateWebXml() throws IOException {
+	private File generateWebXml(ESBServiceEndpointInfo endpointInfo)
+			throws IOException {
 
 		InputStream inTemplate = ClassUtil.getResourceAsStream(
 				"web-xml.template", getClass());
@@ -292,17 +300,15 @@
 		StringWriter strWriter = new StringWriter();
 		IOUtils.copy(inTemplate, strWriter);
 		StringTemplate template = new StringTemplate(strWriter.toString());
-		template.setAttribute("AppName", endpointInfo.getServiceName()
-				.toLowerCase());
-		template.setAttribute("WarName", warName);
-		template.setAttribute("ContextRoot", endpointInfo.getServiceName()
-				.toLowerCase());
+		template.setAttribute("AppName", earName);
+		template.setAttribute("Endpoints", endpointInfos);
 		File appXml = new File("META-INF/application.xml");
 		FileUtils.writeStringToFile(appXml, template.toString());
 		return appXml;
 	}
 
-	private File generateJbossWebXml() throws IOException {
+	private File generateJbossWebXml(ESBServiceEndpointInfo endpointInfo)
+			throws IOException {
 		InputStream inTemplate = ClassUtil.getResourceAsStream(
 				"jbossweb-xml.template", getClass());
 		StringWriter strWriter = new StringWriter();
@@ -315,7 +321,8 @@
 		return jbossWebXml;
 	}
 
-	private File generateWSDLFile() throws IOException {
+	private File generateWSDLFile(ESBServiceEndpointInfo endpointInfo)
+			throws IOException {
 		File wsdlFile = new File("WEB-INF/wsdl/"
 				+ endpointInfo.getWSDLFileName());
 		FileUtils.writeStringToFile(wsdlFile, endpointInfo.getWSDL());

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/JBossWSWebServicePublisher.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -20,17 +20,11 @@
 package org.jboss.internal.soa.esb.webservice;
 
 import java.io.File;
+import java.util.List;
 
 public class JBossWSWebServicePublisher implements WebServicePublisher {
-	public void publish(ESBServiceEndpointInfo endpoint, File esbService) throws WebServicePublishException {
-		JBossWSDeploymentGenerator warGenerator = new JBossWSDeploymentGenerator(endpoint);
-		try {
-			warGenerator.injectWarToESBArchive(esbService);
-		} catch (WebServicePublishException e) {
-			throw new WebServicePublishException(
-					"Failed to publish webservice "
-							+ endpoint.getServiceCategory()+ "/" + endpoint.getServiceName() + " for service "
-							+ esbService.getName(), e);
-		}
+	public void publish(List<ESBServiceEndpointInfo> endpoints, File esbService) throws WebServicePublishException {
+		JBossWSDeploymentGenerator warGenerator = new JBossWSDeploymentGenerator(endpoints);
+	    warGenerator.injectWarToESBArchive(esbService);		
 	}
 }

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/WebServicePublisher.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -20,7 +20,8 @@
 package org.jboss.internal.soa.esb.webservice;
 
 import java.io.File;
+import java.util.List;
 
 public interface WebServicePublisher {
-	void publish(ESBServiceEndpointInfo endpoint, File esbService) throws WebServicePublishException;
+	void publish(List<ESBServiceEndpointInfo> endpoints, File esbService) throws WebServicePublishException;
 }

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/app-xml.template
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/app-xml.template	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/internal/soa/esb/webservice/app-xml.template	2008-06-26 12:38:16 UTC (rev 20798)
@@ -4,11 +4,13 @@
 		"http://java.sun.com/dtd/application_1_3.dtd">
 <application>
 	<display-name>$AppName$</display-name>
-	<module>
+	<module>		
+		$Endpoints:{ endpoint |
 		<web>
-			<web-uri>$WarName$</web-uri>
-			<context-root>$ContextRoot$</context-root>
+			<web-uri>$endpoint.warName$</web-uri>
+			<context-root>$endpoint.warContextRoot$</context-root>
 		</web>
+        }$
 	</module>
 </application>
 

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/Configuration.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -24,28 +24,28 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
 import java.net.URL;
-import java.util.Enumeration;
 import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
+
 import javax.management.ObjectName;
 import javax.xml.transform.stream.StreamSource;
 
 import org.jboss.deployment.DeploymentInfo;
-import org.jboss.internal.soa.esb.publish.ServiceContractPublisher;
 import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.internal.soa.esb.webservice.ESBContractGenerator;
 import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
 import org.jboss.internal.soa.esb.webservice.JBossWSWebServicePublisher;
+import org.jboss.internal.soa.esb.webservice.WebServicePublishException;
 import org.jboss.internal.soa.esb.webservice.WebServicePublisher;
+import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.LifecycleUtil;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.MepType;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycle;
 import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleController;
 import org.jboss.soa.esb.util.ClassUtil;
@@ -133,37 +133,43 @@
 
              // In parallel, create a map of the contract publication info...
              ServicePublisher.addServicePublishers(controller, generator.getModel());
+				//publish esb service as a webService
+		        List<ESBServiceEndpointInfo> endpoints = new java.util.ArrayList<ESBServiceEndpointInfo>();
+				for (Service service : generator.getModel().getServices()) {
+					if (service.getActions().getInXsd() != null) {
+						ESBContractGenerator contractGen = new ESBContractGenerator(
+								service);
+						try {
+							contractGen.generateWSDL(service);
+						} catch (ConfigurationException e) {
+							throw new RuntimeException(
+									"Failed to generate contract for service '"
+											+ service.getCategory() + "/"
+											+ service.getName() + "'", e);
+						}
 
-				List<ServicePublisher> servicePublihsers = ServicePublisher
-						.getServicePublisher(controller);
-
-				// need to publish esb service as a webService?
-
-				for (ServicePublisher publisher : servicePublihsers) {
-
-					if (publisher.getContractPublisher() instanceof ServiceContractPublisher) {
-						//
-						ServiceContractPublisher serviceContractpublisher = (ServiceContractPublisher) publisher
-								.getContractPublisher();
-						String wsdl = serviceContractpublisher.getWSDL();
-						ESBServiceEndpointInfo endpoint = new ESBServiceEndpointInfo(publisher.getCategory(), publisher.getServiceName());
-						MepType.Enum mep  = serviceContractpublisher.getServiceConfig().getActions().getMep() ;
+						ESBServiceEndpointInfo endpoint = new ESBServiceEndpointInfo(
+								service.getCategory(), service.getName());
+						endpoint.setWSDL(contractGen.getWSDL());
+						endpoints.add(endpoint);
+						MepType.Enum mep = service.getActions().getMep();
 						if (mep != null && mep.equals(MepType.ONE_WAY)) {
 							endpoint.setOneway(true);
 						}
-						if (hasPublishedWSWar(esbFile, publisher)) {
-							continue;
-						}
-						genratedWSWar = true;
-						endpoint.setWSDL(wsdl);
-						endpoint.setTargetNamespace("http://soa.jboss.org/"
-								+ publisher.getCategory().toLowerCase());
+
 						endpoint.setDeploymentInfo(di);
-						// publish this esb service to web service
-						WebServicePublisher esbServicePublisher = new JBossWSWebServicePublisher();
-						esbServicePublisher.publish(endpoint, esbFile);
 					}
 				}
+				if (endpoints.size() > 0) {
+					genratedWSWar = true;
+					WebServicePublisher esbServicePublisher = new JBossWSWebServicePublisher();
+					try {
+					    esbServicePublisher.publish(endpoints, esbFile);
+					} catch (WebServicePublishException e) {
+						throw new RuntimeException(
+								"Failed to publish web services for esb :" + di.shortName);						
+					}
+				}
             return controller;
          }
          else
@@ -178,35 +184,7 @@
       }
    }
 
-	private static boolean hasPublishedWSWar(File esbFile,
-			ServicePublisher publisher) {
-		String warName = publisher.getCategory().toLowerCase() + "-"
-				+ publisher.getServiceName().toLowerCase() + ".war";
-		try {
-			if (esbFile.isDirectory()) {
-				File warFile = new File(esbFile.getCanonicalPath(), warName);
-				if (warFile.exists()) {
-					return true;
-				}
-			} else {
-				JarFile esbArchive = new JarFile(esbFile);
 
-				Enumeration<JarEntry> entryEnum = esbArchive.entries();
-				while (entryEnum.hasMoreElements()) {
-					JarEntry jarEntry = (JarEntry) entryEnum.nextElement();
-					if (jarEntry.getName().equalsIgnoreCase(warName)) {
-						return true;
-					}
-				}
-
-			}
-		} catch (IOException e) {
-
-		}
-
-		return false;
-
-	}
 	
 	public static boolean genratedWSWar() {
 		return genratedWSWar;

Modified: labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/src/org/jboss/soa/esb/listeners/config/ServicePublisher.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -10,8 +10,6 @@
 import org.jboss.internal.soa.esb.publish.ActionContractPublisher;
 import org.jboss.internal.soa.esb.publish.ContractPublisher;
 import org.jboss.internal.soa.esb.publish.Publish;
-import org.jboss.internal.soa.esb.publish.ServiceContractPublisher;
-import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.ActionDocument.Action;
 import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
 import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
@@ -177,16 +175,7 @@
                 }
             }
         }
-        if (service.getActions().getInXsd() != null) 
-        {
-           ServiceContractPublisher  publisher = new ServiceContractPublisher(service);
-           try {
-        	     publisher.generateWSDL(service);
-           } catch (ConfigurationException e) {
-        	     throw new RuntimeException("Failed to instantiate ServiceContractPublisher for service '" + service.getCategory() + "/" + service.getName() + "'" , e);
-           }
-           return publisher;
-        }
+
         // No publisher configured on any of the actions in the processing chain...
         return null;
     }

Modified: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGeneratorUnitTest.java
===================================================================
--- labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGeneratorUnitTest.java	2008-06-26 09:45:39 UTC (rev 20797)
+++ labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/JBossWSDeploymentGeneratorUnitTest.java	2008-06-26 12:38:16 UTC (rev 20798)
@@ -21,38 +21,53 @@
 
 import java.io.File;
 import java.net.URL;
+import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 
+import org.jboss.deployment.DeploymentInfo;
+
+
 import junit.framework.TestCase;
 
 public class JBossWSDeploymentGeneratorUnitTest extends TestCase {
 	
-	public void testInjetWar()  {
+	public void testInjetWar() throws Exception {
 		URL url = getClass().getResource("webservice_test.esb");
 		File file = new File(url.getFile());
-		ESBServiceEndpointInfo endpointInfo = new ESBServiceEndpointInfo("MyTest", "test");
-		endpointInfo.setTargetNamespace("http://soa.jboss.org");
-		JBossWSDeploymentGenerator generator = new JBossWSDeploymentGenerator(endpointInfo);
-		boolean warGenerated = false;
-		try {
-			generator.injectWarToESBArchive(file);
-		} catch (Exception e1) {
-			e1.printStackTrace();
+		ESBServiceEndpointInfo endpointInfo1 = new ESBServiceEndpointInfo("jboss", "test1");
+		endpointInfo1.setTargetNamespace("http://soa.jboss.org");
+		
+		ESBServiceEndpointInfo endpointInfo2 = new ESBServiceEndpointInfo("jboss", "test2");
+		endpointInfo2.setTargetNamespace("http://soa.jboss.org");
+		
+		
+		List<ESBServiceEndpointInfo> endpoints = new java.util.ArrayList<ESBServiceEndpointInfo>();
+		DeploymentInfo di = new DeploymentInfo(getClass().getResource("webservice_test.esb"), null, null);
+		endpointInfo1.setDeploymentInfo(di);
+		endpointInfo2.setDeploymentInfo(di);
+		endpoints.add(endpointInfo1);
+		endpoints.add(endpointInfo2);
+		
+		String tmpDir = System.getProperty("java.io.tmpdir");
+		JBossWSDeploymentGenerator generator = new JBossWSDeploymentGenerator(endpoints, new File(tmpDir));
+	    generator.injectWarToESBArchive(file);
+
+	    JarInputStream jarInput = new JarInputStream(new java.io.FileInputStream(file));
+		JarEntry jarEntry = null;
+		boolean war1Generated = false;
+		boolean war2Generated = false;
+		while ((jarEntry = jarInput.getNextJarEntry()) != null) {
+			if (jarEntry.getName().equalsIgnoreCase("jboss-test1.war")) {
+				war1Generated = true;
+			}
+			if (jarEntry.getName().equalsIgnoreCase("jboss-test2.war")) {
+				war2Generated = true;
+			}
 		}
-		try {
-			JarInputStream jarInput = new JarInputStream(new java.io.FileInputStream(file));
-	        JarEntry jarEntry = null;
-	        
-			while ((jarEntry = jarInput.getNextJarEntry()) != null) {
-				if(jarEntry.getName().equalsIgnoreCase("mytest.war")) {
-					warGenerated = true;
-				}
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-		} 
-		assertTrue("the war does not injected into esb file", warGenerated);
+		
+		assertTrue("The jboss-test1.war does not generated in esb archive", war1Generated);
+		assertTrue("The jboss-test1.war does not generated in esb archive", war2Generated);
 	}
 
 }

Modified: labs/jbossesb/workspace/jimma/product/rosetta/tests/src/org/jboss/internal/soa/esb/webservice/webservice_test.esb
===================================================================
(Binary files differ)




More information about the jboss-svn-commits mailing list