incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r794243 - /sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
Date Wed, 15 Jul 2009 12:04:06 GMT
Author: cziegeler
Date: Wed Jul 15 12:04:06 2009
New Revision: 794243

URL: http://svn.apache.org/viewvc?rev=794243&view=rev
Log:
Fix resource handling (packages are separated by a slash not by a dot)

Modified:
    sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java

Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java?rev=794243&r1=794242&r2=794243&view=diff
==============================================================================
--- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
(original)
+++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java
Wed Jul 15 12:04:06 2009
@@ -46,12 +46,17 @@
         return (exportedPackage == null ? null : exportedPackage.getExportingBundle());
     }
 
+    private String getPackageFromResource(final String resource) {
+        final int lastSlash = resource.lastIndexOf('/');
+        String pck = resource.substring(0, lastSlash + 1).replace('/', '.');
+        return pck + "Dummy";
+    }
     /**
      * @see java.lang.ClassLoader#getResources(java.lang.String)
      */
     @SuppressWarnings("unchecked")
     public Enumeration<URL> getResources(String name) throws IOException {
-        final Bundle bundle = this.findBundleForClassOrResource(name);
+        final Bundle bundle = this.findBundleForClassOrResource(getPackageFromResource(name));
         if ( bundle == null ) {
             return super.getResources(name);
         }
@@ -62,7 +67,7 @@
      * @see java.lang.ClassLoader#findResource(java.lang.String)
      */
     public URL findResource(String name) {
-        final Bundle bundle = this.findBundleForClassOrResource(name);
+        final Bundle bundle = this.findBundleForClassOrResource(getPackageFromResource(name));
         if ( bundle == null ) {
             return super.findResource(name);
         }



Mime
View raw message