[jboss-cvs] JBossAS SVN: r91701 - in trunk/webservices/src: main/org/jboss/wsf/container/jboss60/deployer and 18 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 28 02:43:23 EDT 2009


Author: beve
Date: 2009-07-28 02:43:23 -0400 (Tue, 28 Jul 2009)
New Revision: 91701

Added:
   trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/WSVirtualFileFilter.java
   trunk/webservices/src/test/
   trunk/webservices/src/test/java/
   trunk/webservices/src/test/java/org/
   trunk/webservices/src/test/java/org/jboss/
   trunk/webservices/src/test/java/org/jboss/wsf/
   trunk/webservices/src/test/java/org/jboss/wsf/container/
   trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/
   trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/deployer/
   trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHookTest.java
   trunk/webservices/src/test/resources/
   trunk/webservices/src/test/resources/archives/
   trunk/webservices/src/test/resources/archives/additional-none/
   trunk/webservices/src/test/resources/archives/additional-none/META-INF/
   trunk/webservices/src/test/resources/archives/additional-none/META-INF/MANIFEST.MF
   trunk/webservices/src/test/resources/archives/additional-wsdl/
   trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/
   trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/MANIFEST.MF
   trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/dummy.wsdl
   trunk/webservices/src/test/resources/archives/additional-xml/
   trunk/webservices/src/test/resources/archives/additional-xml/META-INF/
   trunk/webservices/src/test/resources/archives/additional-xml/META-INF/MANIFEST.MF
   trunk/webservices/src/test/resources/archives/additional-xml/META-INF/dummy.xml
   trunk/webservices/src/test/resources/archives/additional-xsd/
   trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/
   trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/MANIFEST.MF
   trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/dummy.xsd
Modified:
   trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHook.java
Log:
Merge of https://jira.jboss.org/jira/browse/JBWS-2619 "Consider DeploymentUnit's metadataLocation in ArchiveDeployment.getMetadataFileURL(..)"


Modified: trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHook.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHook.java	2009-07-28 06:24:00 UTC (rev 91700)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHook.java	2009-07-28 06:43:23 UTC (rev 91701)
@@ -21,8 +21,16 @@
  */
 package org.jboss.wsf.container.jboss60.deployer;
 
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.logging.Logger;
+import org.jboss.metadata.serviceref.VirtualFileAdaptor;
+import org.jboss.virtual.VirtualFile;
 import org.jboss.wsf.spi.SPIProvider;
 import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.deployment.*;
@@ -39,6 +47,8 @@
 {
    // provide logging
    protected final Logger log = Logger.getLogger(getClass());
+   
+   private static final WSVirtualFileFilter WS_FILEFILTER = new WSVirtualFileFilter();
 
    private DeploymentAspectManager deploymentAspectManager;
    private DeploymentModelFactory deploymentModelFactory;
@@ -79,6 +89,19 @@
       {
          DeploymentModelFactory factory = getDeploymentModelFactory();
          ArchiveDeployment dep = (ArchiveDeployment)factory.newDeployment(unit.getSimpleName(), unit.getClassLoader());
+         if (unit instanceof VFSDeploymentUnit)
+         {
+            VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+            List<VirtualFile> virtualFiles = vfsUnit.getMetaDataFiles(WS_FILEFILTER);
+            Set<UnifiedVirtualFile> uVirtualFiles = new HashSet<UnifiedVirtualFile>();
+            for (VirtualFile vf : virtualFiles)
+            {
+               // Adding the roots of the virtual files.
+               uVirtualFiles.add(new VirtualFileAdaptor(vf.getVFS().getRoot()));
+            }
+            dep.setMetadataFiles(new LinkedList<UnifiedVirtualFile>(uVirtualFiles));
+         }
+         
          if (unit.getParent() != null)
          {
             DeploymentUnit parentUnit = unit.getParent();

Added: trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/WSVirtualFileFilter.java
===================================================================
--- trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/WSVirtualFileFilter.java	                        (rev 0)
+++ trunk/webservices/src/main/org/jboss/wsf/container/jboss60/deployer/WSVirtualFileFilter.java	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,81 @@
+/*
+ * 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.wsf.container.jboss60.deployer;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilterWithAttributes;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * VirtualFileFilter that can be used to search/filter files with the 
+ * suffix ".wsdl", ".xsd", and ".xml".
+ * <p/>
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class WSVirtualFileFilter implements VirtualFileFilterWithAttributes
+{
+   /** The attributes */
+   private VisitorAttributes attributes;
+
+   /**
+    * No-args constructor. 
+    * 
+    * Will create a recursive filter by setting {@link VisitorAttributes#RECURSE_LEAVES_ONLY}.
+    */
+   public WSVirtualFileFilter()
+   {
+      this(VisitorAttributes.RECURSE_LEAVES_ONLY);
+   }
+
+   /**
+    * 
+    * @param attributes The {@link VisitorAttributes} value which determines the recursive behaviour of this filter.
+    */
+   public WSVirtualFileFilter(final VisitorAttributes attributes)
+   {
+      this.attributes = attributes;
+   }
+
+   /**
+    * Retrieves the VisitorAttribute for this instance.
+    */
+   public VisitorAttributes getAttributes()
+   {
+      return attributes;
+   }
+
+   /**
+    * Accepts files that end with .wsdl and .xsd.
+    * 
+    * @return {@code true} If the file name ends with either .wsdl or .xsd. Otherwise returns false.
+    */
+   public boolean accepts(final VirtualFile file)
+   {
+      if (file == null)
+         return false;
+
+      final String fileName = file.getName();
+      return fileName.endsWith(".wsdl") || fileName.endsWith(".xsd") || fileName.endsWith(".xml");
+   }
+
+}

Added: trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHookTest.java
===================================================================
--- trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHookTest.java	                        (rev 0)
+++ trunk/webservices/src/test/java/org/jboss/wsf/container/jboss60/deployer/AbstractDeployerHookTest.java	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,137 @@
+/*
+ * 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.wsf.container.jboss60.deployer;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentUnit;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+
+/**
+ * Unit test for {@link AbstractDeployerHook}.
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class AbstractDeployerHookTest extends TestCase
+{
+    /*
+     * Directory can be found in src/test/resources
+     */
+    private static final String RESOURCES_DIR = "/archives";
+    
+    public void testNoAdditionalFiles() throws IOException, DeploymentException
+    {
+        final String archive_name = "additional-none";
+        final AbstractVFSDeploymentUnit deploymentUnit = createDeploymentUnit(RESOURCES_DIR, archive_name);
+        
+        final AbstractDeployerHook deployerHook = new MockAbstractDeployerHook();
+        final ArchiveDeployment archiveDeployment = deployerHook.newDeployment(deploymentUnit);
+        
+        assertEquals(0, archiveDeployment.getMetadataFiles().size());
+    }
+    
+    public void testAdditionalXsd() throws IOException, DeploymentException
+    {
+        final String archive_name = "additional-xsd";
+		final AbstractVFSDeploymentUnit deploymentUnit = createDeploymentUnit(RESOURCES_DIR, archive_name);
+		
+        final AbstractDeployerHook deployerHook = new MockAbstractDeployerHook();
+		final ArchiveDeployment archiveDeployment = deployerHook.newDeployment(deploymentUnit);
+		
+		assertEquals(1, archiveDeployment.getMetadataFiles().size());
+		assertNotNull(archiveDeployment.getMetaDataFileURL(archive_name + "/META-INF/dummy.xsd"));
+    }
+    
+    public void testAdditionalWsdl() throws IOException, DeploymentException
+    {
+        final String archive_name = "additional-wsdl";
+        final AbstractVFSDeploymentUnit deploymentUnit = createDeploymentUnit(RESOURCES_DIR, archive_name);
+        
+        final AbstractDeployerHook deployerHook = new MockAbstractDeployerHook();
+        final  ArchiveDeployment archiveDeployment = deployerHook.newDeployment(deploymentUnit);
+        
+        assertEquals(1, archiveDeployment.getMetadataFiles().size());
+        assertNotNull(archiveDeployment.getMetaDataFileURL(archive_name + "/META-INF/dummy.wsdl"));
+    }
+    
+    public void testAdditionalXml() throws IOException, DeploymentException
+    {
+        final String archive_name = "additional-xml";
+        final AbstractDeployerHook deployerHook = new MockAbstractDeployerHook();
+        final AbstractVFSDeploymentUnit deploymentUnit = createDeploymentUnit(RESOURCES_DIR, archive_name);
+        
+        final ArchiveDeployment archiveDeployment = deployerHook.newDeployment(deploymentUnit);
+        
+        assertEquals(1, archiveDeployment.getMetadataFiles().size());
+        assertNotNull(archiveDeployment.getMetaDataFileURL(archive_name + "/META-INF/dummy.xml"));
+    }
+    
+    private AbstractVFSDeploymentUnit createDeploymentUnit(final String context, final String archiveName) throws IOException, DeploymentException
+    {
+        final URL archivesDir = getClass().getResource(context);
+        final VirtualFile root = VFS.getVirtualFile(archivesDir, archiveName);
+       
+        final VFSStructuralDeployersImpl structuralDeployers = new VFSStructuralDeployersImpl();
+        final VFSStructureBuilder builder = new VFSStructureBuilder();
+        structuralDeployers.setStructureBuilder(builder);
+        structuralDeployers.addDeployer(new JARStructure());
+        
+        final VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(root);
+        final VFSDeploymentContext deploymentContext = (VFSDeploymentContext)structuralDeployers.determineStructure(deployment);
+        deploymentContext.setClassLoader(getClass().getClassLoader());
+        return new AbstractVFSDeploymentUnit(deploymentContext);
+    }
+    
+    private class MockAbstractDeployerHook extends AbstractDeployerHook
+    {
+        @Override
+        public DeploymentType getDeploymentType()
+        {
+            return null;
+        }
+
+        public void deploy(DeploymentUnit unit) throws DeploymentException
+        {
+            //NoOp
+        }
+
+        public void undeploy(DeploymentUnit unit)
+        {
+            //NoOp
+        }
+    }
+
+}

Added: trunk/webservices/src/test/resources/archives/additional-none/META-INF/MANIFEST.MF
===================================================================
--- trunk/webservices/src/test/resources/archives/additional-none/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/webservices/src/test/resources/archives/additional-none/META-INF/MANIFEST.MF	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+

Added: trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/MANIFEST.MF
===================================================================
--- trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/MANIFEST.MF	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+

Added: trunk/webservices/src/test/resources/archives/additional-wsdl/META-INF/dummy.wsdl
===================================================================

Added: trunk/webservices/src/test/resources/archives/additional-xml/META-INF/MANIFEST.MF
===================================================================
--- trunk/webservices/src/test/resources/archives/additional-xml/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/webservices/src/test/resources/archives/additional-xml/META-INF/MANIFEST.MF	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+

Added: trunk/webservices/src/test/resources/archives/additional-xml/META-INF/dummy.xml
===================================================================

Added: trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/MANIFEST.MF
===================================================================
--- trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/MANIFEST.MF	2009-07-28 06:43:23 UTC (rev 91701)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Created-By: 1.5.0_06 (Sun Microsystems Inc.)
+

Added: trunk/webservices/src/test/resources/archives/additional-xsd/META-INF/dummy.xsd
===================================================================




More information about the jboss-cvs-commits mailing list