hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind status.xml
Date Sat, 04 Sep 2004 14:38:50 GMT
hlship      2004/09/04 07:38:50

  Modified:    framework/src/java/org/apache/hivemind/service/impl Tag:
                        branch-1-0 ClassFactoryImpl.java
                        HiveMindClassPool.java CtClassSource.java
                        ClassFactoryClassLoader.java
               framework/src/test/org/apache/hivemind/service/impl Tag:
                        branch-1-0 TestClassFab.java
               .        Tag: branch-1-0 status.xml
  Log:
  HIVEMIND-49: Fix a class loading issue inside Tomcat.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.6.2.1   +5 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryImpl.java
  
  Index: ClassFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.6.2.1
  diff -u -r1.6 -r1.6.2.1
  --- ClassFactoryImpl.java	31 Aug 2004 20:02:13 -0000	1.6
  +++ ClassFactoryImpl.java	4 Sep 2004 14:38:49 -0000	1.6.2.1
  @@ -68,7 +68,11 @@
   
           if (result == null)
           {
  -            result = new CtClassSource(_pool, module.getClassResolver().getClassLoader());
  +            ClassLoader moduleLoader = module.getClassResolver().getClassLoader();
  +
  +            _pool.appendClassLoader(moduleLoader);
  +
  +            result = new CtClassSource(_pool);
   
               _ctClassSourceMap.put(id, result);
           }
  
  
  
  1.1.2.1   +22 -5     jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/HiveMindClassPool.java
  
  Index: HiveMindClassPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/HiveMindClassPool.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- HiveMindClassPool.java	31 Aug 2004 20:02:13 -0000	1.1
  +++ HiveMindClassPool.java	4 Sep 2004 14:38:50 -0000	1.1.2.1
  @@ -14,8 +14,12 @@
   
   package org.apache.hivemind.service.impl;
   
  +import java.util.HashSet;
  +import java.util.Set;
  +
   import javassist.ClassPath;
   import javassist.ClassPool;
  +import javassist.LoaderClassPath;
   
   /**
    * Used to ensure that {@link javassist.ClassPool#appendClassPath(javassist.ClassPath)}
is
  @@ -28,19 +32,32 @@
   {
       private ClassFactoryClassLoader _loader = new ClassFactoryClassLoader();
   
  +    /**
  +     * Used to identify which class loaders have already been integrated into the pool.
  +     */
  +    private Set _loaders = new HashSet();
  +
       public HiveMindClassPool()
       {
           super(null);
       }
   
       /**
  -     * Synchronizes this operation.  {@link ClassPool#get(java.lang.String)} is already
  -     * synchronized. 
  -     *
  +     * Convienience method for adding to the ClassPath for a particular
  +     * class loader.
        */
  -    public synchronized ClassPath appendClassPath(ClassPath cp)
  +    public synchronized void appendClassLoader(ClassLoader loader)
       {
  -        return super.appendClassPath(cp);
  +        if (_loaders.contains(loader))
  +            return;
  +
  +        _loader.addDelegateLoader(loader);
  +
  +        ClassPath path = new LoaderClassPath(loader);
  +
  +        appendClassPath(path);
  +
  +        _loaders.add(loader);
       }
   
       public Class loadClass(String name, byte[] bytecodes)
  
  
  
  1.2.2.1   +1 -7      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/CtClassSource.java
  
  Index: CtClassSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/CtClassSource.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- CtClassSource.java	31 Aug 2004 20:02:13 -0000	1.2
  +++ CtClassSource.java	4 Sep 2004 14:38:50 -0000	1.2.2.1
  @@ -14,9 +14,7 @@
   
   package org.apache.hivemind.service.impl;
   
  -import javassist.ClassPath;
   import javassist.CtClass;
  -import javassist.LoaderClassPath;
   import javassist.NotFoundException;
   
   import org.apache.hivemind.ApplicationRuntimeException;
  @@ -34,13 +32,9 @@
   {
       private HiveMindClassPool _pool;
   
  -    public CtClassSource(HiveMindClassPool pool, ClassLoader parentLoader)
  +    public CtClassSource(HiveMindClassPool pool)
       {
           _pool = pool;
  -
  -        ClassPath path = new LoaderClassPath(parentLoader);
  -
  -        _pool.appendClassPath(path);
       }
   
       public CtClass getCtClass(Class searchClass)
  
  
  
  1.3.2.1   +52 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryClassLoader.java
  
  Index: ClassFactoryClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ClassFactoryClassLoader.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- ClassFactoryClassLoader.java	31 Aug 2004 20:02:13 -0000	1.3
  +++ ClassFactoryClassLoader.java	4 Sep 2004 14:38:50 -0000	1.3.2.1
  @@ -14,6 +14,9 @@
   
   package org.apache.hivemind.service.impl;
   
  +import java.util.ArrayList;
  +import java.util.List;
  +
   /**
    * ClassLoader used to properly instantiate newly created classes.
    *
  @@ -22,6 +25,11 @@
    */
   class ClassFactoryClassLoader extends ClassLoader
   {
  +    private List _loaders = new ArrayList();
  +
  +    /**
  +     * Invoked to create a new class instance from fabricated bytecode.
  +     */
       public Class loadClass(String name, byte[] bytecodes)
       {
           Class result = defineClass(name, bytecodes, 0, bytecodes.length);
  @@ -30,4 +38,48 @@
   
           return result;
       }
  +
  +    /**
  +     * Adds a delegate class loader to the list of delegate class loaders.
  +     */
  +    public synchronized void addDelegateLoader(ClassLoader loader)
  +    {
  +        _loaders.add(loader);
  +    }
  +
  +    /**
  +     * Searches each of the delegate class loaders for the given class.
  +     */
  +    protected synchronized Class findClass(String name) throws ClassNotFoundException
  +    {
  +        ClassNotFoundException cnfex = null;
  +
  +        try
  +        {
  +            return super.findClass(name);
  +        }
  +        catch (ClassNotFoundException ex)
  +        {
  +            cnfex = ex;
  +        }
  +
  +        int count = _loaders.size();
  +        for (int i = 0; i < count; i++)
  +        {
  +            ClassLoader l = (ClassLoader) _loaders.get(i);
  +
  +            try
  +            {
  +                return l.loadClass(name);
  +            }
  +            catch (ClassNotFoundException ex)
  +            {
  +            }
  +        }
  +
  +        // Not found .. through the first exception
  +
  +        throw cnfex;
  +    }
  +
   }
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +15 -2     jakarta-hivemind/framework/src/test/org/apache/hivemind/service/impl/TestClassFab.java
  
  Index: TestClassFab.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/service/impl/TestClassFab.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- TestClassFab.java	31 Aug 2004 20:02:14 -0000	1.1
  +++ TestClassFab.java	4 Sep 2004 14:38:50 -0000	1.1.2.1
  @@ -40,8 +40,20 @@
    */
   public class TestClassFab extends HiveMindTestCase
   {
  -    private CtClassSource _source =
  -        new CtClassSource(new HiveMindClassPool(), Thread.currentThread().getContextClassLoader());
  +    private CtClassSource _source;
  +
  +    protected void setUp() throws Exception
  +    {
  +        super.setUp();
  +
  +        ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
  +
  +        HiveMindClassPool pool = new HiveMindClassPool();
  +
  +        pool.appendClassLoader(threadLoader);
  +
  +        _source = new CtClassSource(pool);
  +    }
   
       private ClassFab newClassFab(String className, Class superClass)
       {
  @@ -387,4 +399,5 @@
           // Javassist lets us down here; I can't think of a way to get addField() to actually
           // fail.
       }
  +
   }
  
  
  
  No                   revision
  No                   revision
  1.57.2.1  +4 -2      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.57
  retrieving revision 1.57.2.1
  diff -u -r1.57 -r1.57.2.1
  --- status.xml	4 Sep 2004 13:45:28 -0000	1.57
  +++ status.xml	4 Sep 2004 14:38:50 -0000	1.57.2.1
  @@ -22,7 +22,7 @@
       <person name="Knut Wannheden" email="knut.wannheden@paranor.ch" id="KW" />
     </developers>
     <todo>
  -    <actions priority="Release 1.0">
  +    <actions priority="Release 1.1">
         <action context="lib" dev="HLS">JMX Integration</action>
       </actions>
     </todo>
  @@ -43,7 +43,9 @@
         <action type="fix" dev="HLS" fixes-bug="HIVEMIND-44" due-to="James Carman">
           The previous fix was incomplete; this should close the remaining sychronization
gaps.
         </action>
  -      
  +      <action type="fix" dev="HLS" fixed-bug="HIVEMIND-49">
  +        Class loading issue inside Tomcat.
  +      </action>
       </release>
     
       <release version="1.0-rc-1" date="Aug 25 2004">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message