[weld-commits] Weld SVN: r6238 - java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue May 18 07:32:13 EDT 2010


Author: peteroyle
Date: 2010-05-18 07:32:13 -0400 (Tue, 18 May 2010)
New Revision: 6238

Modified:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
Log:
WELDSE-26: Previous commit for this issue broke simple jar support. This commit fixes.

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java	2010-05-17 13:30:55 UTC (rev 6237)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java	2010-05-18 11:32:13 UTC (rev 6238)
@@ -84,14 +84,9 @@
          for (URL url : urlEnum)
          {
 
-            String urlPath;
-            try
-            {
-               urlPath = URLDecoder.decode(url.toExternalForm(), "UTF-8");
-            } catch (UnsupportedEncodingException ex)
-            {
-               throw new ClasspathScanningException("Error decoding URL using UTF-8");
-            }
+            String urlPath = url.toExternalForm();
+
+            // determin resource type (eg: jar, file, bundle)
             String urlType = "file";
             int colonIndex = urlPath.indexOf(":");
             if (colonIndex != -1)
@@ -99,20 +94,39 @@
                urlType = urlPath.substring(0, colonIndex);
             }
 
-            // hack for /META-INF/beans.xml
-            if (urlPath.indexOf('!') == -1)
+            // Extra built-in support for simple file-based resources
+            if ("file".equals(urlType) || "jar".equals(urlType))
             {
-               File dirOrArchive = new File(urlPath);
-               if ((resourceName != null) && (resourceName.lastIndexOf('/') > 0))
+               // switch to using getPath() instead of toExternalForm()
+               urlPath = url.getPath();
+
+               if (urlPath.indexOf('!') > 0)
                {
-                  dirOrArchive = dirOrArchive.getParentFile();
+                  urlPath = urlPath.substring(0, urlPath.indexOf('!'));
+               } else
+               {
+                  // hack for /META-INF/beans.xml
+                  File dirOrArchive = new File(urlPath);
+                  if ((resourceName != null) && (resourceName.lastIndexOf('/') > 0))
+                  {
+                     dirOrArchive = dirOrArchive.getParentFile();
+                  }
+                  urlPath = dirOrArchive.getParent();
                }
-               urlPath = dirOrArchive.getParent();
             }
 
+            try
+            {
+               urlPath = URLDecoder.decode(urlPath, "UTF-8");
+            } catch (UnsupportedEncodingException ex)
+            {
+               throw new ClasspathScanningException("Error decoding URL using UTF-8");
+            }
+
             log.debug("URL Type: " + urlType);
 
             paths.put(urlType, urlPath);
+
          }
       }
       for (String urlType : paths.keySet())



More information about the weld-commits mailing list