[jboss-cvs] JBossAS SVN: r103083 - projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 28 07:33:15 EDT 2010


Author: alesj
Date: 2010-03-28 07:33:15 -0400 (Sun, 28 Mar 2010)
New Revision: 103083

Modified:
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DirectRootResourceOwnerFinder.java
Log:
Fix root lookup.

Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DirectRootResourceOwnerFinder.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DirectRootResourceOwnerFinder.java	2010-03-28 11:24:59 UTC (rev 103082)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/DirectRootResourceOwnerFinder.java	2010-03-28 11:33:15 UTC (rev 103083)
@@ -27,12 +27,13 @@
 import java.security.AccessController;
 import java.security.PrivilegedExceptionAction;
 
-import org.jboss.classloading.plugins.vfs.VFSResourceVisitor;
 import org.jboss.classloading.spi.visitor.ResourceContext;
-import org.jboss.vfs.VirtualFile;
 
 /**
  * Direct root finder.
+ * 
+ * We asume underlying resource context implements RootAwareResource.
+ * If this is not the case, use different ROF impl.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
@@ -45,16 +46,15 @@
    {
       try
       {
-         final Class<?> clazz = VFSResourceVisitor.class;
          SecurityManager sm = System.getSecurityManager();
          if (sm == null)
-            currentRootGetter = clazz.getDeclaredMethod("getCurrentRoot");
+            currentRootGetter = getLookupMethod();
          else
             currentRootGetter = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>()
             {
                public Method run() throws Exception
                {
-                  return clazz.getDeclaredMethod("getCurrentRoot");
+                  return getLookupMethod();
                }
             });
       }
@@ -63,6 +63,13 @@
       }
    }
 
+   private static Method getLookupMethod() throws Exception
+   {
+      ClassLoader cl = ResourceContext.class.getClassLoader();
+      Class<?> clazz = cl.loadClass("org.jboss.classloading.spi.visitor.RootAwareResource");
+      return clazz.getDeclaredMethod("getRootUrl");
+   }
+
    private DirectRootResourceOwnerFinder()
    {
    }
@@ -89,9 +96,12 @@
    {
       try
       {
-         VirtualFile file = (VirtualFile) currentRootGetter.invoke(null);
-         return file.toURL();
+         return (URL) currentRootGetter.invoke(resource);
       }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
       catch (Exception e)
       {
          throw new RuntimeException(e);




More information about the jboss-cvs-commits mailing list