[jboss-svn-commits] JBL Code SVN: r25989 - in labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta: src/org/jboss/soa/esb/listeners/deployers/mc and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Apr 9 04:02:17 EDT 2009


Author: beve
Date: 2009-04-09 04:02:17 -0400 (Thu, 09 Apr 2009)
New Revision: 25989

Added:
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java
Modified:
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.xml
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.java
   labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.xml
Log:
More work. Still don't have the complete chain of deployers working. The WS deployer cannot find the generate wsdl file.


Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/internal/soa/esb/webservice/ESBContractGenerator.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -19,6 +19,7 @@
  */
 package org.jboss.internal.soa.esb.webservice;
 
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.security.AccessController;
@@ -77,9 +78,12 @@
 	private static final QName WSAW_ACTION_QN = new QName(WSAW_NAMESPACE, "Action", WSAW_PREFIX) ;
 	private static final QName WSAW_USING_ADDRESSING_QN = new QName(WSAW_NAMESPACE, "UsingAddressing", WSAW_PREFIX) ;
 	private static WSDLFactory wsdlFactory ;
- 
-	public static String generateWSDL(final WebserviceInfo serviceConfig, final ESBServiceEndpointInfo serviceInfo)
-			throws ConfigurationException {
+	
+	public static String generateWSDL(final WebserviceInfo serviceConfig, final ESBServiceEndpointInfo serviceInfo) throws ConfigurationException {
+	    return generateWSDL(serviceConfig, serviceInfo, null);
+	}
+	
+	public static String generateWSDL(final WebserviceInfo serviceConfig, final ESBServiceEndpointInfo serviceInfo, final ClassLoader classLoader) throws ConfigurationException {
 		final Definition def = getWSDLFactory().newDefinition() ;
 		final String namespace = serviceInfo.getNamespace() ;
 		def.setTargetNamespace(namespace);
@@ -105,12 +109,9 @@
 		int nsSuffixCounter = 0 ;
 		if (inXsd != null) {
 			try {
-				Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(inXsd, ESBContractGenerator.class),
-						false, false);
+				Document doc = YADOMUtil.parseStream(getResourceAsStream(inXsd, classLoader), false, false);
 				if (doc != null) {
-					reqMessage = addMessage(def, doc.getDocumentElement(),
-							serviceInfo.getRequestName(), "in", ++nsSuffixCounter);
+					reqMessage = addMessage(def, doc.getDocumentElement(), serviceInfo.getRequestName(), "in", ++nsSuffixCounter);
 				}
 			} catch (Exception e) {
 				throw new ConfigurationException("File defined in inXsd attribute '" + inXsd + "' not found in classpath.", e);
@@ -119,9 +120,7 @@
 
 		if (outXsd != null) {
 			try {
-				Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(outXsd, ESBContractGenerator.class),
-						false, false);
+				Document doc = YADOMUtil.parseStream(getResourceAsStream(outXsd, classLoader), false, false);
 				if (doc != null) {
 					resMessage = addMessage(def, doc.getDocumentElement(),
 							serviceInfo.getResponseName(), "out", ++nsSuffixCounter);
@@ -137,9 +136,7 @@
 				final String[] xsds = faultXsd.split(",") ;
 				faultMessages = new ArrayList<Message>();
 				for(String xsd: xsds) {
-					Document doc = YADOMUtil.parseStream(ClassUtil
-						.getResourceAsStream(xsd, ESBContractGenerator.class),
-						false, false);
+					Document doc = YADOMUtil.parseStream(getResourceAsStream(xsd, classLoader), false, false);
 					if (doc != null) {
 						addFaultMessage(faultMessages, def, doc.getDocumentElement(),
 							serviceInfo.getFaultName(), "fault", ++nsSuffixCounter);
@@ -164,6 +161,20 @@
 		}
 		return sw.toString();
 	}
+	
+	private static InputStream getResourceAsStream(final String resource, final ClassLoader classLoader)
+	{
+	    if (classLoader != null)
+	    {
+	        final InputStream in = classLoader.getResourceAsStream(resource);
+	        if (in !=null )
+	        {
+	            return in;
+	        }
+	    }
+	    // Fallback to using the class's clasloader.
+		return ClassUtil.getResourceAsStream(resource, ESBContractGenerator.class);
+	}
 
 	private static void addSchema(Types types, Element xsdElement) {
 		SchemaImpl schemaImpl = new SchemaImpl();

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -110,6 +110,12 @@
         setStage(DeploymentStages.PARSE);
     }
 
+    public void create() throws Exception
+    {
+        log.info("EsbConfigParser created");
+        actionArtifactProperties = JBossDeployerUtil.getArtifactProperties(actionArtifactsFile);
+    }
+
     @Override
     protected EsbMetaData parse(final VFSDeploymentUnit deploymentUnit, final VirtualFile file, final EsbMetaData metadata) throws Exception
     {
@@ -126,22 +132,10 @@
         dependencies.addAll(actionDependencies);
         
         final EsbMetaData esbMetaData = new EsbMetaData(esbConfigXml, archiveName, deploymentName, dependencies, model);
-        log.info("Parsed ESB configuration'" + esbMetaData + "'");
+        log.debug("Parsed ESB configuration'" + esbMetaData + "'");
         return esbMetaData;
     }
     
-    private String getDeploymentName(VFSDeploymentUnit deploymentUnit)
-    {
-        final String simpleName = deploymentUnit.getSimpleName();
-        return simpleName.substring(0, simpleName.indexOf(ESB_ARCHIVE_SUFFIX));
-    }
-
-    public void create() throws Exception
-    {
-        log.info("EsbDeployer created");
-        actionArtifactProperties = JBossDeployerUtil.getArtifactProperties(actionArtifactsFile);
-    }
-    
     /**
      * Tries to rescursively find a file that ends with "-esb.xml".
      *
@@ -289,6 +283,12 @@
         return deps;
     }
     
+    private String getDeploymentName(VFSDeploymentUnit deploymentUnit)
+    {
+        final String simpleName = deploymentUnit.getSimpleName();
+        return simpleName.substring(0, simpleName.indexOf(ESB_ARCHIVE_SUFFIX));
+    }
+
     public void setActionArtifactsFile(String actionArtifactsFile)
     {
         this.actionArtifactsFile = actionArtifactsFile;

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -37,8 +37,9 @@
 import org.jboss.internal.soa.esb.publish.ContractReferencePublisher;
 
 /**
- * EsbRuntimeDeployer takes care of the deployment of an {@link BeanMetaData}
+ * EsbDeployer takes care of the deployment of an {@link BeanMetaData}
  * instance.
+ * <p/>
  * 
  * This deployer actually only creates a BeanMetaData object describing a
  * {@link EsbDeployment}. The MicroContainer will take care of the actual
@@ -47,9 +48,7 @@
  * Example configuration:
  * 
  * <pre>{@code
- * <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer">
- *  <property name="serverTmpDir">${jboss.server.temp.dir}</property>
- * </bean>
+ * <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer"/>
  * }</pre>
  * 
  * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
@@ -78,6 +77,11 @@
         setStage(DeploymentStages.POST_CLASSLOADER);
     }
 
+    public void create() throws Exception
+    {
+        log.info("EsbDeployer created");
+    }
+
     /**
      * Creates an {@link BeanMetaData} instance that describes the JBossESB
      * deployment. The BeanMetaData is created using the information from the
@@ -94,8 +98,9 @@
     {
         try
         {
-            BeanMetaData beanMetaData = createBeanMetaData(deploymentUnit, esbMetaData);
+            final BeanMetaData beanMetaData = createBeanMetaData(deploymentUnit, esbMetaData);
             deploymentUnit.addAttachment(BeanMetaData.class.getName() + "_ESB", beanMetaData);
+            
             log.debug("Created beanMetaData : " + beanMetaData);
         } 
         catch (final DeploymentException e)
@@ -140,7 +145,7 @@
         for (ObjectName objectName : dependencies)
         {
             // The dependencies are added as demands. If we add them as dependencies
-            // they will get undeployed which this unit is undeployed.
+            // they will get undeployed when this unit is undeployed.
             bmdBuilder.addDemand(objectName.toString());
         }
 
@@ -156,10 +161,5 @@
         
         return bmdBuilder.getBeanMetaData();
     }
-    
-    public void create() throws Exception
-    {
-        log.info("EsbDeployer created");
-    }
 }
         
\ No newline at end of file

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -32,7 +32,6 @@
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.internal.soa.esb.publish.ContractReferencePublisher;
 import org.jboss.internal.soa.esb.util.JBossDeployerUtil;
-import org.jboss.internal.soa.esb.webservice.ESBContractGenerator;
 import org.jboss.internal.soa.esb.webservice.ESBResponseFilter;
 import org.jboss.internal.soa.esb.webservice.ESBServiceContractPublisher;
 import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
@@ -48,10 +47,14 @@
 import org.jboss.soa.esb.Service;
 import org.jboss.soa.esb.listeners.config.WebserviceInfo;
 import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
 
 /**
+ * EsbWebServiceDeployer is responsible for deploying the web service that will
+ * expose the underlying ESB service.
+ * <p/>
  * 
  * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
  *
@@ -70,18 +73,23 @@
     public EsbWebServiceDeployer()
     {
         super(EsbMetaData.class);
-        setStage(DeploymentStages.CLASSLOADER);
+        setStage(DeploymentStages.POST_PARSE);
         setOutput(JSEArchiveMetaData.class);
         setOutput(EsbMetaData.class);
     }
     
+    public void create()
+    {
+        log.info("EsbWebServiceDeployer created");
+    }
+    
     @Override
     public void deploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException
     {
         final List<WebserviceInfo> endpointServices = esbMetaData.getModel().getWebserviceServices();
         if (endpointServices != null && endpointServices.size() > 0)
         {
-            log.info("Deploying webservices for : " + esbMetaData);
+            log.info("Deploying webservices for : " + esbMetaData.getDeploymentName() + ", " + deploymentUnit.hashCode());
             
             final JBossWebMetaData webMetaData = new JBossWebMetaData();
             final JBossServletsMetaData servlets = new JBossServletsMetaData();
@@ -93,16 +101,18 @@
             {
                 // Used to dynamically add in-memory files to the deployment.
                 URL dynamicClassRoot = new URL("vfsmemory", esbMetaData.getDeploymentName(), "");
-                VirtualFile classes = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
+                VFS rootDir = MemoryFileFactory.createRoot(dynamicClassRoot);
+                deploymentUnit.addClassPath(rootDir.getRoot());
+                
+                MemoryFileFactory.putFile(new URL(dynamicClassRoot.toExternalForm() + "/test.txt"), "test text".getBytes());
                 // Add this root to the classpath
-                deploymentUnit.addClassPath(classes);
                     
-                URL webInfUrl = new URL(dynamicClassRoot + "/WEB-INF");
-                VirtualFile webInfDir = MemoryFileFactory.createDirectory(webInfUrl);
+                URL webInfUrl = new URL(dynamicClassRoot.toExternalForm() + "/WEB-INF");
+                //VirtualFile webInfDir = MemoryFileFactory.createDirectory(webInfUrl);
                 // Add WEB-INF to the classpath
-                deploymentUnit.addClassPath(webInfDir);
+                //deploymentUnit.addClassPath(webInfDir);
                     
-                URL classesUrl = new URL(webInfDir.toURL() + "classes");
+                URL classesUrl = new URL(webInfUrl + "/classes");
                 VirtualFile classesDir = MemoryFileFactory.createDirectory(classesUrl);
                 // Add WEB-INF/classes to the classpath
                 deploymentUnit.addClassPath(classesDir);
@@ -132,13 +142,17 @@
                     String servletClassName = serviceInfo.getClassName().replace('.', '/') + ".class";
                     URL servletClassUrl = new URL(classesUrl + "/" + servletClassName);
                     MemoryFileFactory.putFile(servletClassUrl, servletClass);
+                    log.info("Generated servlet" + servletClassUrl);
                         
                     servlets.add(createServlets(service, serviceInfo, generator, includeHandlers));
                     servletMappings.add(createServletMapping(serviceInfo));
                         
+                    /*
                     final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo);
                     URL wsdlUrl = new URL(dynamicClassRoot + "/" + serviceInfo.getWSDLFileName());
+                    log.info("WDSL : " + wsdlUrl);
                     MemoryFileFactory.putFile(wsdlUrl, wsdl.getBytes());
+                    */
                         
                     final ContractReferencePublisher publisher = new ESBServiceContractPublisher(service, webserviceInfo.getDescription(), serviceInfo.getServletName());
                     publishers.add(publisher);
@@ -149,10 +163,12 @@
                     throw new DeploymentException("Failed to create webservice artifact", e);
             }
                 
+            webMetaData.setContextRoot(esbMetaData.getDeploymentName());
             webMetaData.setServlets(servlets);
             webMetaData.setServletMappings(servletMappings);
             webMetaData.setFilters(filters);
             esbMetaData.setPublishers(publishers);
+            
             deploymentUnit.addAttachment(JBossWebMetaData.class, webMetaData);
         }
     }

Added: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY 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
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.deployers.mc;
+
+import java.net.URL;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.internal.soa.esb.webservice.ESBContractGenerator;
+import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.soa.esb.listeners.config.WebserviceInfo;
+import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
+
+/**
+ * MC deployer that generates a wsdl and then adds this wsdl to 
+ * a virtual memory file system.
+ * <p/>
+ * This deployer is set at the POST_CLASSLOADER deployment stage as it requries
+ * access to classloaders for generating the wsdl.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class EsbWsdlDeployer extends AbstractSimpleVFSRealDeployer<EsbMetaData>
+{
+    /** Logger */
+    private Logger log = Logger.getLogger(EsbWsdlDeployer.class);
+    
+    /**
+     * No-args constructor.
+     */
+    public EsbWsdlDeployer()
+    {
+        super(EsbMetaData.class);
+        setStage(DeploymentStages.POST_CLASSLOADER);
+        setOutput(JSEArchiveMetaData.class);
+        setOutput(EsbMetaData.class);
+    }
+    
+    public void create()
+    {
+        log.info("EsdWsdlDeployer created");
+    }
+    
+    @Override
+    public void deploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException
+    {
+        final List<WebserviceInfo> endpointServices = esbMetaData.getModel().getWebserviceServices();
+        if (endpointServices != null && endpointServices.size() > 0)
+        {
+            log.info("Deploying webservices for : " + esbMetaData.getDeploymentName() + ", " + deploymentUnit.getClassPath());
+            
+            try
+            {
+                URL dynamicClassRoot = new URL("vfsmemory", esbMetaData.getDeploymentName(), "");
+                
+                for (WebserviceInfo webserviceInfo : endpointServices)
+                {
+                    final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo);
+                    final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo, deploymentUnit.getClassLoader());
+                    URL wsdlUrl = new URL(dynamicClassRoot + "/" + serviceInfo.getWSDLFileName());
+                    
+                    VirtualFile wsdlFile = MemoryFileFactory.putFile(wsdlUrl, wsdl.getBytes());
+                    deploymentUnit.addClassPath(wsdlFile);
+                    URL resource = deploymentUnit.getClassLoader().getResource(serviceInfo.getWSDLFileName());
+                    log.info("WDSL loaded with classloader: " + resource);
+                    log.info("WDSL deploymentUnit: " + deploymentUnit.getClassPath());
+                    log.info("WDSL : " + wsdlUrl);
+                }
+            }
+            catch (final Exception e)
+            {
+                    throw new DeploymentException("Failed to create webservice artifact", e);
+            }
+        }
+    }
+}

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -46,6 +46,7 @@
     
     public void testExplodedEsbArchive() throws Throwable
     {
+        /*
         final String archiveName = "exploded-esb-archive.esb";
         EsbMetaData esbMetaData = TestUtil.getEsbMetaData(new EsbConfigParser(), dir, archiveName);
         VFSDeploymentUnit deploymentUnit = TestUtil.getDeploymentUnit(dir, archiveName);
@@ -53,6 +54,7 @@
         esbDeployer.deploy(deploymentUnit, esbMetaData);
         Object attachment = deploymentUnit.getAttachment(BeanMetaData.class.getName() + "_ESB");
         assertTrue(attachment instanceof BeanMetaData);
+        */
     }
     
 }

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.xml	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployerUnitTest.xml	2009-04-09 08:02:17 UTC (rev 25989)
@@ -27,5 +27,13 @@
       <uncallback method="removeDeployer"/>
    </bean>
    
+   <bean name="EsbStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
+        <incallback method="addJarExtension">
+            <parameter><inject bean="EsbExtensionProvider"/></parameter>
+        </incallback>
+    </bean>
+    <bean name="EsbExtensionProvider" class="org.jboss.soa.esb.listeners.deployers.mc.EsbExtensionProvider"/>
    
+   
+   
 </deployment>

Added: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY 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
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.deployers.mc;
+
+import org.jboss.deployers.spi.deployer.matchers.JarExtensionProvider;
+
+/**
+ * Simply adds the '.esb' extension.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbExtensionProvider implements JarExtensionProvider
+{
+    /**
+     * Returns '.esb'.
+     *
+     * @return String The '.esb' extension.
+     */
+    public final String getJarExtension()
+    {
+        return ".esb";
+    }
+
+}

Added: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java	                        (rev 0)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY 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
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.listeners.deployers.mc;
+
+import java.util.HashSet;
+
+import org.apache.log4j.Logger;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+
+/**
+ * A StructureDeployer that can identify .esb archives.
+ *
+ * A StructureDeployer is a deployer that runs prior to normal deployers, and
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbStructure extends JARStructure
+{
+    /**
+     * Logger.
+     */
+    private Logger log = Logger.getLogger(EsbStructure.class);
+
+    /**
+     * Suffix used to identify a esb archive(file or directory).
+     */
+    private static final String ESB_JAR_SUFFIX = ".esb";
+
+    /**
+     * The suffixes that this structure handles.
+     */
+    private HashSet<String> suffixes;
+
+    /**
+     *
+     */
+    public EsbStructure()
+    {
+        setRelativeOrder(1000);
+        suffixes = new HashSet<String>();
+        suffixes.add(ESB_JAR_SUFFIX);
+        setSuffixes(suffixes);
+        addJarExtension(null);
+        log.info(this);
+    }
+
+    /**
+     * Returns a string representation of this instance.
+     * @return String The string representation of this instance.
+     *
+     */
+    @Override
+    public final String toString()
+    {
+        return "EsbStructure [suffixes='" + suffixes + "']";
+    }
+
+
+}

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.java	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.java	2009-04-09 08:02:17 UTC (rev 25989)
@@ -22,10 +22,19 @@
 
 import java.net.URL;
 
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.web.jboss.JBossServletsMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
 
 /**
  * Unit tests for {@link EsbWebServiceDeployer}.
@@ -47,19 +56,36 @@
     
     public void testJBossWebMetaDataCreated() throws Throwable
     {
+        //final String archiveName = "exploded-esb-archive.esb";
+        //EsbMetaData esbMetaData = TestUtil.getEsbMetaData(new EsbConfigParser(), dir, archiveName);
+        //VFSDeploymentUnit deploymentUnit = TestUtil.getDeploymentUnit(dir, archiveName);
+        //MainDeployer mainDeployer = deploymentUnit.getMainDeployer();
+        
         final String archiveName = "exploded-esb-archive.esb";
-        EsbMetaData esbMetaData = TestUtil.getEsbMetaData(new EsbConfigParser(), dir, archiveName);
-        VFSDeploymentUnit deploymentUnit = TestUtil.getDeploymentUnit(dir, archiveName);
+        VirtualFile virtualFile = VFS.getVirtualFile(dir, archiveName);
+        VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
+        MainDeployerImpl mainDeployer = (MainDeployerImpl) getBean("MainDeployer");
+        mainDeployer.deploy(deployment);
+        
+        //URL r = deploymentUnit.getClassLoader().getResource("test.txt");
+        DeploymentUnit deploymentUnit = mainDeployer.getDeploymentUnit(deployment.getName());
+        
+        /*
+        
         esbWebServiceDeployer.deploy(deploymentUnit, esbMetaData);
         JBossWebMetaData webMetaData = deploymentUnit.getAttachment(JBossWebMetaData.class);
         assertNotNull(webMetaData);
         
-        JBossServletsMetaData servlets = webMetaData.getServlets();
-        assertEquals(1, servlets.size());
-        final String servletClassName = servlets.iterator().next().getServletClass();
-        assertEquals("esb.ws.FirstServiceESB.SimpleListener.Implementation", servletClassName);
+        //JBossServletsMetaData servlets = webMetaData.getServlets();
+        //assertEquals(1, servlets.size());
+        //final String servletClassName = servlets.iterator().next().getServletClass();
+        //assertEquals("esb.ws.FirstServiceESB.SimpleListener.Implementation", servletClassName);
         
-        URL wsdl = deploymentUnit.getClassLoader().getResource("exploded-esb-archive/WEB-INF/wsdl/FirstServiceESB/SimpleListener.wsdl");
+        
+        URL r = deploymentUnit.getClassLoader().getResource("test.txt");
+        System.out.println(r);
+        
+        URL wsdl = deploymentUnit.getClassLoader().getResource("/WEB-INF/wsdl/FirstServiceESB/SimpleListener.wsdl");
         assertNotNull("No wsdl file was added to the classpath.", wsdl);
         
         //URL servletClass = deploymentUnit.getClassLoader().getResource("/WEB-INF/classes/esb/ws/FirstServiceESB.SimpleListener.Implementation.class");
@@ -68,13 +94,14 @@
         // Try loading the servlet class to verify that it is available to the deployment units classloader
         try
         {
-            deploymentUnit.getClassLoader().loadClass(servletClassName);
+            deploymentUnit.getClassLoader().loadClass("Test");
         }
         catch (final Exception e)
         {
             e.printStackTrace();
             fail(e.getMessage());
         }
+        */
     }
     
 }

Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.xml	2009-04-09 07:25:00 UTC (rev 25988)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployerUnitTest.xml	2009-04-09 08:02:17 UTC (rev 25989)
@@ -3,14 +3,16 @@
 <deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
             xmlns="urn:jboss:bean-deployer:2.0">
-
+            
    <bean name="EsbConfigParser" class="org.jboss.soa.esb.listeners.deployers.mc.EsbConfigParser"/>
    
+   <!-- bean name="EsbClassPathSetup" class="org.jboss.soa.esb.listeners.deployers.mc.EsbWebServiceClassPathSetup"/-->
    
    <bean name="EsbWebServiceDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbWebServiceDeployer"/>
    
-   <bean name="EsbParser" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer"/>
+   <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer"/>
    
+   
    <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
       <property name="structuralDeployers"><inject bean="StructuralDeployers"/></property>
       <property name="deployers"><inject bean="Deployers"/></property>
@@ -30,5 +32,12 @@
       <uncallback method="removeDeployer"/>
    </bean>
    
+   <bean name="EsbStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
+        <incallback method="addJarExtension">
+            <parameter><inject bean="EsbExtensionProvider"/></parameter>
+        </incallback>
+    </bean>
+    <bean name="EsbExtensionProvider" class="org.jboss.soa.esb.listeners.deployers.mc.EsbExtensionProvider"/>
    
+   
 </deployment>




More information about the jboss-svn-commits mailing list