commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsi...@apache.org
Subject cvs commit: jakarta-commons/discovery/src/java/org/apache/commons/discovery ServiceFinder.java ClassFinder.java
Date Tue, 09 Jul 2002 21:12:01 GMT
rsitze      2002/07/09 14:12:01

  Modified:    discovery/src/java/org/apache/commons/discovery
                        ServiceFinder.java ClassFinder.java
  Log:
  Corrected caching behavior.  Wasn't looking at all classloaders when going through cache.
  
  Revision  Changes    Path
  1.3       +7 -10     jakarta-commons/discovery/src/java/org/apache/commons/discovery/ServiceFinder.java
  
  Index: ServiceFinder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/ServiceFinder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceFinder.java	9 Jul 2002 20:45:20 -0000	1.2
  +++ ServiceFinder.java	9 Jul 2002 21:12:01 -0000	1.3
  @@ -162,16 +162,13 @@
       {
           /**
            * Return previously registered service object (not class)
  -         * for this spi.  Try contextClassLoader first, and if that
  -         * fails then try the spi's class loader.
  +         * for this spi.  Try each class loader in succession.
            */
  -        Object service = (spiContext.getThreadContextClassLoader() == null)
  -                ? null
  -                : get(spiContext.getSPI().getName(), spiContext.getThreadContextClassLoader());
  -        
  -        if (service == null) {
  -            service = get(spiContext.getSPI().getName(),
  -                          spiContext.getSPI().getClassLoader());
  +        Object service = null;
  +        ClassLoader[] allLoaders = classFinder.getAllLoaders();
  +
  +        for (int idx = 0; service == null  &&  idx < allLoaders.length; idx++)
{
  +            service = get(spiContext.getSPI().getName(), allLoaders[idx]);
           }
   
           if (service != null) {        
  @@ -504,7 +501,7 @@
        */
       private static Object get(String spi, ClassLoader classLoader)
       {
  -        ServiceCache cache = (spi == null)
  +        ServiceCache cache = (spi == null  ||  classLoader == null)
                                ? null
                                : (ServiceCache)service_caches.get(spi);
           
  
  
  
  1.2       +2 -0      jakarta-commons/discovery/src/java/org/apache/commons/discovery/ClassFinder.java
  
  Index: ClassFinder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/discovery/src/java/org/apache/commons/discovery/ClassFinder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassFinder.java	9 Jul 2002 18:03:23 -0000	1.1
  +++ ClassFinder.java	9 Jul 2002 21:12:01 -0000	1.2
  @@ -94,6 +94,8 @@
       
       private final ClassLoader[] localLoaders;
       private final ClassLoader[] allLoaders;
  +    
  +    ClassLoader[] getAllLoaders() { return allLoaders; }
   
       public ClassFinder(SPIContext spiContext, Class rootFinderClass) {
           this.spiContext = spiContext;
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message