Changeset 7196


Ignore:
Timestamp:
Aug 30, 2016, 1:48:40 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #2027: Improve inter-communication between extensions

Fixed the findResource(), findResources() and hasChanged() methods so that they also search the proxied JAR files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/JarClassLoader.java

    r7194 r7196  
    417417    if (url == null) url = findResource(name);
    418418
     419    // 3. Side-load from proxied JAR files (eg. other extensions)
     420    if (url == null)
     421    {
     422      Iterator<JarClassLoaderProxy> it = proxyLoaders.iterator();
     423      while (url == null && it.hasNext())
     424      {
     425        JarClassLoaderProxy proxyLoader = it.next();
     426        url = proxyLoader.findResource(name);
     427      }
     428    }
     429
    419430    // 3. Check with parent loader if not done so already
    420431    if (url == null && !delegateFirst)
     
    442453    if (delegateFirst) addResources(resources, parentResources);
    443454    addResources(resources, myResources);
     455    Iterator<JarClassLoaderProxy> it = proxyLoaders.iterator();
     456    while (it.hasNext())
     457    {
     458      JarClassLoaderProxy proxyLoader = it.next();
     459      addResources(resources, proxyLoader.findResources(name));
     460    }
     461
    444462    if (!delegateFirst) addResources(resources, parentResources);
    445463   
     
    498516        }
    499517        if (!isSame) return true;
     518      }
     519      for (JarClassLoaderProxy proxy : proxyLoaders)
     520      {
     521        if (proxy.hasChanged()) return true;
    500522      }
    501523    }
     
    846868      return c;
    847869    }
     870   
     871    URL findResource(String name)
     872    {
     873      if (log.isDebugEnabled()) log.debug("JarClassLoaderProxy.findResource[" + jarPath + "]: " + name);
     874      if (!isInitialized) init();
     875     
     876      URL url = null;
     877      if (loader != null)
     878      {
     879        url = loader.findResource(name);
     880      }
     881      return url;
     882    }
     883   
     884    Enumeration<URL> findResources(String name)
     885    {
     886      if (log.isDebugEnabled()) log.debug("JarClassLoaderProxy.findResources[" + jarPath + "]: " + name);
     887      if (!isInitialized) init();
     888     
     889      Enumeration<URL> url = null;
     890      if (loader != null)
     891      {
     892        url = loader.findResources(name);
     893      }
     894      return url;
     895    }
     896   
     897    boolean hasChanged()
     898    {
     899      if (!isInitialized) return false;
     900      if (loader != null) return loader.hasChanged(true);
     901      return new File(jarPath).exists();
     902    }
    848903  }
    849904}
Note: See TracChangeset for help on using the changeset viewer.