Skip to content

Commit

Permalink
WELDSE-26: Previous commit for this issue broke simple jar support. T…
Browse files Browse the repository at this point in the history
…his commit fixes.
  • Loading branch information
peteroyle committed May 18, 2010
1 parent 8de7f0f commit 7a0efc3
Showing 1 changed file with 28 additions and 14 deletions.
Expand Up @@ -84,35 +84,49 @@ public void scanResources(String[] resources)
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)
{
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)
{
urlPath = urlPath.substring(0, urlPath.indexOf('!'));
} else
{
dirOrArchive = dirOrArchive.getParentFile();
// 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())
Expand Down

0 comments on commit 7a0efc3

Please sign in to comment.