[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-cvs-commits
Subject:    [jboss-cvs] jmx/src/main/org/jboss/mx/loading HeirarchicalLoaderRepository3.java
From:       Scott M Stark <starksm () users ! sourceforge ! net>
Date:       2004-05-31 23:48:27
Message-ID: E1BUwW3-0000BI-0U () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

  User: starksm 
  Date: 04/05/31 16:48:26

  Modified:    src/main/org/jboss/mx/loading Tag: Branch_3_2
                        HeirarchicalLoaderRepository3.java
  Log:
  The parentRepository.getResource(String, ClassLoader) call cannot be used to
  locate a resource as this can lead to the parentRepository holding onto a
  class loader from the HeirarchicalLoaderRepository which results in class
  leaks.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.16  +36 -5     jmx/src/main/org/jboss/mx/loading/HeirarchicalLoaderRepository3.java
  
  Index: HeirarchicalLoaderRepository3.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/org/jboss/mx/loading/HeirarchicalLoaderRepository3.java,v
  retrieving revision 1.1.4.15
  retrieving revision 1.1.4.16
  diff -u -r1.1.4.15 -r1.1.4.16
  --- HeirarchicalLoaderRepository3.java	24 Jan 2004 19:55:56 -0000	1.1.4.15
  +++ HeirarchicalLoaderRepository3.java	31 May 2004 23:48:26 -0000	1.1.4.16
  @@ -27,7 +27,7 @@
    * first and then the parent depending on the java2ParentDelegation flag.
    *
    * @author Scott.Stark@jboss.org
  - * @version $Revision: 1.1.4.15 $
  + * @version $Revision: 1.1.4.16 $
    */
   public class HeirarchicalLoaderRepository3 extends UnifiedLoaderRepository3
   {
  @@ -308,9 +308,12 @@
   
         if( java2ParentDelegation == true )
         {
  -         // Try this repository
  -         resource = parentRepository.getResource(name, scl);
  -         // Next try our parent repository
  +         /* Try our parent repository. This cannot use the getResource method
  +         because we do not want the parent repository to load the resource via
  +         our scoped class loader
  +         */
  +         resource = getParentResource(name, scl);
  +         // Next try this repository
            if( resource == null )
               resource = super.getResource(name, scl);
         }
  @@ -320,7 +323,13 @@
            resource = super.getResource(name, scl);
            // Next try our parent repository
            if( resource == null )
  -            resource = parentRepository.getResource(name, scl);
  +         {
  +            /* Try our parent repository. This cannot use the getResource method
  +            because we do not want the parent repository to load the resource via
  +            our scoped class loader
  +            */
  +            resource = getParentResource(name, scl);
  +         }
         }
   
         return resource;
  @@ -453,4 +462,26 @@
         return theSet;
      }
   
  +   /** A subset of the functionality found in getResource(String, ClassLoader),
  +    * but this version queries the parentRepository and does not use the scl
  +    * to avoid leaking class loaders across scoped.
  +    * 
  +    * @param name - the resource name
  +    * @param scl - the requesting class loader
  +    * @return the resource URL if found, null otherwise
  +    */ 
  +   private URL getParentResource(String name, ClassLoader scl)
  +   {
  +      // Not found in classloader, ask the global cache
  +      URL resource = parentRepository.getResourceFromGlobalCache(name);
  +
  +      // The cache has it, we are done
  +      if (resource != null)
  +         return resource;
  +
  +      // Not visible in global cache, iterate on all classloaders
  +      resource = parentRepository.getResourceFromRepository(name, scl);
  +
  +      return resource;
  +   }
   }
  
  
  


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic