[jbossws-commits] JBossWS SVN: r8606 - in stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro: metadata and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Oct 30 15:55:30 EDT 2008


Author: alessio.soldano at jboss.com
Date: 2008-10-30 15:55:30 -0400 (Thu, 30 Oct 2008)
New Revision: 8606

Modified:
   stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java
   stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/VFSResourceLoader.java
Log:
[JBWS-2374] Now actually collecting docs (imported wsdl and xml) from META-INF/wsdl and WEB-INF/wsdl


Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java	2008-10-30 19:50:00 UTC (rev 8605)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java	2008-10-30 19:55:30 UTC (rev 8606)
@@ -135,34 +135,26 @@
       this.loader = loader;
       this.container = container;
       this.adapterFactory = adapterFactory;
-
-      // toggle EJB and WEB deployments
-      String resourcePath = "/META-INF/";
+      findDocs("/META-INF/wsdl/");
+      findDocs("/WEB-INF/wsdl/");
+      logger.fine("metadata=" + docs);
+   }
+   
+   private void findDocs(String resourcePath)
+   {
       try
       {
          URL resource = loader.getResource(resourcePath);
-         InputStream inputStream = null;
-         try
+         if (resource != null)
          {
-            inputStream = resource.openStream();
+         log.debug("Collecting docs from " + resourcePath);
+         collectDocs(resourcePath);
          }
-         finally
-         {
-            if(inputStream!=null)
-               inputStream.close();
-         }
-
-         log.warn("bypass collectDocs(), it doesnt work for EJB endpoints");
       }
       catch (Exception e)
       {
-         resourcePath = "/WEB-INF/";
-         log.debug("Collecting docs from " + resourcePath);
-
-         collectDocs(resourcePath+"wsdl/");
-         logger.fine("metadata=" + docs);
+         //ignore
       }
-
    }
 
    /**

Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/VFSResourceLoader.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/VFSResourceLoader.java	2008-10-30 19:50:00 UTC (rev 8605)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/VFSResourceLoader.java	2008-10-30 19:55:30 UTC (rev 8606)
@@ -21,24 +21,23 @@
  */
 package org.jboss.wsf.stack.metro.metadata;
 
-import com.sun.xml.ws.transport.http.ResourceLoader;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.logging.Logger;
-
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Set;
 import java.util.List;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.jar.JarFile;
-import java.util.jar.JarEntry;
+import java.util.Set;
 
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
+import com.sun.xml.ws.transport.http.ResourceLoader;
+
 /**
  * @author Heiko.Braun at jboss.com
+ * @author alessio.soldano at jboss.com
  */
 public class VFSResourceLoader implements ResourceLoader
 {
@@ -59,7 +58,8 @@
          if(path.startsWith("/"))
             path = path.substring(1, path.length());
 
-         return vfs.findChild(path).toURL();
+         UnifiedVirtualFile uvf = vfs.findChild(path);
+         return uvf != null ? uvf.toURL() : null;
       }
       catch (IOException e)
       {
@@ -76,7 +76,7 @@
       }
       catch (MalformedURLException e)
       {
-         // ingore
+         // ignore
       }
       return resource;
    }
@@ -84,75 +84,29 @@
    public Set<String> getResourcePaths(String path)
    {
       Set<String> resources = new HashSet<String>();
-
+      resources.addAll(getFileResources(path));
+      return resources;
+   }
+   
+   private List<String> getFileResources(String path)
+   {
+      List<String> resources = new ArrayList<String>();
       try
       {
-         URL rootUrl = getResource(path);
-         if(rootUrl.getProtocol().equals("jar"))
+         if(path.startsWith("/"))
+            path = path.substring(1, path.length());
+         List<UnifiedVirtualFile> list = vfs.findChild(path).getChildren();
+         for (UnifiedVirtualFile uvf : list)
          {
-            /*String urlString = rootUrl.toExternalForm();
-            String jarRoot = urlString.substring(4, urlString.indexOf("jar!")+3);
-           
-            File jar = new File(jarRoot);
-            assert jar.exists();
-            JarFile jarFile = new JarFile(jar);
-            
-            List<String> jarResources = getJARResources(jarFile, path);
-
-            resources.addAll(jarResources);*/
-            log.warn("Cannot collect resourcePaths from EJB jar");
+            String name = uvf.getName();
+            if (name != null && (name.endsWith(File.separator) || name.endsWith(".xml") || name.endsWith(".xsd") || name.endsWith(".wsdl")))
+               resources.add(path + uvf.getName());
          }
-         else
-         {
-            File root = new File(  rootUrl.toURI() );
-            List<String> fileResources = getFileResources(root, path);
-            resources.addAll(fileResources);
-         }
       }
-      catch (Exception e)
+      catch (Throwable e)
       {
          log.error("Failed to read resource paths from '"+path+"': ", e);
       }
-
       return resources;
    }
-
-   private static List<String> getFileResources(File root, String path)
-   {
-      List<String> resources = new ArrayList<String>();
-
-      if(root.exists())
-      {
-         File[] files = root.listFiles();
-         if (files != null) {
-            for( File f : files) {
-               if(f.isDirectory()) {
-                  resources.add(path+f.getName()+'/');
-               } else {
-                  resources.add(path+f.getName());
-               }
-            }
-         }
-      }
-      return resources;
-   }
-
-   private static List<String> getJARResources(JarFile jarFile, String path) {
-      List<String> resources = new ArrayList<String>();
-
-      Enumeration entries = jarFile.entries();
-      while (entries.hasMoreElements()) {
-         JarEntry entry = (JarEntry) entries.nextElement();
-         String entryName = entry.getName();
-
-         if (entryName.matches(".*?\\.xml$")
-           || entryName.matches(".*?\\.wsdl$")
-           || entryName.matches(".*?\\.xsd$"))
-         {
-            resources.add(entryName);
-         }
-      }
-
-      return resources;
-   }
 }




More information about the jbossws-commits mailing list