[jbosscache-commits] JBoss Cache SVN: r4871 - core/trunk/src/main/java/org/jboss/cache/factories/annotations.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Dec 18 10:03:42 EST 2007
Author: manik.surtani at jboss.com
Date: 2007-12-18 10:03:42 -0500 (Tue, 18 Dec 2007)
New Revision: 4871
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/annotations/ClasspathScanner.java
Log:
Make this work on Hudson
Modified: core/trunk/src/main/java/org/jboss/cache/factories/annotations/ClasspathScanner.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/annotations/ClasspathScanner.java 2007-12-18 14:49:44 UTC (rev 4870)
+++ core/trunk/src/main/java/org/jboss/cache/factories/annotations/ClasspathScanner.java 2007-12-18 15:03:42 UTC (rev 4871)
@@ -6,6 +6,7 @@
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
@@ -44,17 +45,18 @@
*/
public <T> Set<Class<? extends T>> scan(Class<? extends Annotation> annotationType, Class<T> classType)
{
- // only scan the current ClassPath location that contains this file. Could be a directory or a JAR file.
- URL url = getURLPathFromClassLoader();
- String urlPath = url.getFile();
- if (urlPath.endsWith("/"))
- {
- urlPath = urlPath.substring(0, urlPath.length() - 1);
- }
+ Set<Class<? extends T>> classes = Collections.emptySet();
- Set<Class<? extends T>> classes = Collections.emptySet();
try
{
+ // only scan the current ClassPath location that contains this file. Could be a directory or a JAR file.
+ URL url = getURLPathFromClassLoader();
+ String urlPath = url.getFile();
+ if (urlPath.endsWith("/"))
+ {
+ urlPath = urlPath.substring(0, urlPath.length() - 1);
+ }
+
if (log.isDebugEnabled()) log.debug("scanning: " + urlPath);
File file = new File(urlPath);
if (file.isDirectory())
@@ -78,7 +80,7 @@
return classes;
}
- private URL getURLPathFromClassLoader()
+ private URL getURLPathFromClassLoader() throws MalformedURLException
{
URL u2 = classLoader.findResource("org/jboss/cache/Version.class");
@@ -87,7 +89,7 @@
String urlString = u.toString().replaceAll("\\/\\.\\/", "/");
if (u2.toString().startsWith(urlString))
{
- return u;
+ return new URL(urlString);
}
}
More information about the jbosscache-commits
mailing list