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/library/src/java/org/apache/hivemind/lib/pipeline BridgeBuilder.java
Date Mon, 13 Sep 2004 14:48:17 GMT
hlship      2004/09/13 07:48:17

  Modified:    framework/src/java/org/apache/hivemind/service/impl
                        CtClassSource.java HiveMindClassPool.java
                        LoggingInterceptorFactory.java
                        ClassFactoryImpl.java ClassFactoryClassLoader.java
               src/documentation/content/xdocs index.xml
               framework/src/test/org/apache/hivemind/service/impl
                        TestClassFab.java
               framework/src/java/org/apache/hivemind/impl
                        ProxyBuilder.java
               library/src/java/org/apache/hivemind/lib/impl
                        EJBProxyFactory.java ServicePropertyFactory.java
                        DefaultImplementationBuilderImpl.java
               framework/src/java/org/apache/hivemind/util
                        PropertyUtils.java
               hivebuild dist.xml
               framework/src/java/org/apache/hivemind/test
                        HiveMindTestCase.java
               .        version.properties status.xml
               framework/src/java/org/apache/hivemind/service
                        ClassFactory.java
               library/src/test/org/apache/hivemind/lib/pipeline
                        TestPipelineAssembler.java TestBridgeBuilder.java
               framework/src/java/org/apache/hivemind/schema/rules
                        SmartTranslator.java
               framework/src/test/hivemind/test/rules
                        TestSmartTranslator.java
               library/src/test/hivemind/test/lib
                        TestDefaultImplementationBuilder.java
               library/src/test/org/apache/hivemind/lib/impl
                        TestServicePropertyFactory.java
               library/src/java/org/apache/hivemind/lib/pipeline
                        BridgeBuilder.java
  Added:       framework/src/java/org/apache/hivemind/service
                        MethodIterator.java
               framework/src/test/org/apache/hivemind/impl
                        TestMethodIterator.java
  Log:
  Merge changes from branch-1-0 into HEAD.
  
  Revision  Changes    Path
  1.3       +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.3
  diff -u -r1.2 -r1.3
  --- CtClassSource.java	31 Aug 2004 20:02:13 -0000	1.2
  +++ CtClassSource.java	13 Sep 2004 14:48:15 -0000	1.3
  @@ -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.2       +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.2
  diff -u -r1.1 -r1.2
  --- HiveMindClassPool.java	31 Aug 2004 20:02:13 -0000	1.1
  +++ HiveMindClassPool.java	13 Sep 2004 14:48:15 -0000	1.2
  @@ -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.9       +7 -11     jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java
  
  Index: LoggingInterceptorFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/LoggingInterceptorFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LoggingInterceptorFactory.java	18 Aug 2004 19:34:11 -0000	1.8
  +++ LoggingInterceptorFactory.java	13 Sep 2004 14:48:15 -0000	1.9
  @@ -15,7 +15,6 @@
   package org.apache.hivemind.service.impl;
   
   import java.lang.reflect.Constructor;
  -import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.Iterator;
   import java.util.List;
  @@ -32,6 +31,7 @@
   import org.apache.hivemind.service.ClassFactory;
   import org.apache.hivemind.service.MethodContribution;
   import org.apache.hivemind.service.MethodFab;
  +import org.apache.hivemind.service.MethodIterator;
   import org.apache.hivemind.service.MethodSignature;
   
   /**
  @@ -147,25 +147,21 @@
   
       protected void addServiceMethods(InterceptorStack stack, ClassFab fab, List parameters)
       {
  -        boolean toString = false;
  -        Method[] methods = stack.getServiceInterface().getMethods();
  -
           MethodMatcher matcher = buildMethodMatcher(parameters);
   
  -        for (int i = 0; i < methods.length; i++)
  +        MethodIterator mi = new MethodIterator(stack.getServiceInterface());
  +
  +        while (mi.hasNext())
           {
  -            Method m = methods[i];
  -            MethodSignature sig = new MethodSignature(m);
  +            MethodSignature sig = mi.next();
   
               if (includeMethod(matcher, sig))
                   addServiceMethodImplementation(fab, sig);
               else
                   addPassThruMethodImplementation(fab, sig);
  -
  -            toString |= ClassFabUtils.isToString(m);
           }
   
  -        if (!toString)
  +        if (!mi.getToString())
               addToStringMethod(stack, fab);
       }
   
  @@ -210,7 +206,7 @@
   
           String name = ClassFabUtils.generateClassName("Interceptor");
   
  -        ClassFab classFab = _factory.newClass(name, Object.class, module);
  +        ClassFab classFab = _factory.newClass(name, Object.class, module.getClassResolver().getClassLoader());
   
           classFab.addInterface(serviceInterfaceClass);
   
  
  
  
  1.7       +19 -25    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.7
  diff -u -r1.6 -r1.7
  --- ClassFactoryImpl.java	31 Aug 2004 20:02:13 -0000	1.6
  +++ ClassFactoryImpl.java	13 Sep 2004 14:48:15 -0000	1.7
  @@ -14,13 +14,12 @@
   
   package org.apache.hivemind.service.impl;
   
  -import java.util.HashMap;
  -import java.util.Map;
  +import java.util.HashSet;
  +import java.util.Set;
   
   import javassist.CtClass;
   
   import org.apache.hivemind.ApplicationRuntimeException;
  -import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.service.ClassFab;
   import org.apache.hivemind.service.ClassFactory;
   
  @@ -32,24 +31,22 @@
   public class ClassFactoryImpl implements ClassFactory
   {
       /**
  -     * Map of CtClassSource, keyed on module id.
  -     */
  -    private Map _ctClassSourceMap = new HashMap();
  -
  -    /**
        * ClassPool shared by all modules (all CtClassSource instances).
        */
       private HiveMindClassPool _pool = new HiveMindClassPool();
  +    private CtClassSource _classSource = new CtClassSource(_pool);
   
  -    public ClassFab newClass(String name, Class superClass, Module module)
  +    private Set _addedClassLoaders = new HashSet();
  +
  +    public ClassFab newClass(String name, Class superClass, ClassLoader loader)
       {
  -        CtClassSource source = findCtClassSource(module);
  +        updateSourceForClassLoader(loader);
   
           try
           {
  -            CtClass ctNewClass = source.newClass(name, superClass);
  +            CtClass ctNewClass = _classSource.newClass(name, superClass);
   
  -            return new ClassFabImpl(source, ctNewClass);
  +            return new ClassFabImpl(_classSource, ctNewClass);
           }
           catch (Exception ex)
           {
  @@ -57,23 +54,20 @@
                   ServiceMessages.unableToCreateClass(name, superClass, ex),
                   ex);
           }
  -
       }
   
  -    private synchronized CtClassSource findCtClassSource(Module module)
  +    /**
  +     * Whenever a new class loader is encountered (which is, actually, 
  +     * fairly rare), update the pool (and, indirectly, the class source)
  +     * to search it as well.
  +     */
  +    private synchronized void updateSourceForClassLoader(ClassLoader loader)
       {
  -        String id = module.getModuleId();
  -
  -        CtClassSource result = (CtClassSource) _ctClassSourceMap.get(id);
  -
  -        if (result == null)
  -        {
  -            result = new CtClassSource(_pool, module.getClassResolver().getClassLoader());
  +        if (_addedClassLoaders.contains(loader))
  +            return;
   
  -            _ctClassSourceMap.put(id, result);
  -        }
  +        _pool.appendClassLoader(loader);
   
  -        return result;
  +        _addedClassLoaders.add(loader);
       }
  -
   }
  
  
  
  1.4       +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.4
  diff -u -r1.3 -r1.4
  --- ClassFactoryClassLoader.java	31 Aug 2004 20:02:13 -0000	1.3
  +++ ClassFactoryClassLoader.java	13 Sep 2004 14:48:15 -0000	1.4
  @@ -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;
  +    }
  +
   }
  
  
  
  1.17      +2 -6      jakarta-hivemind/src/documentation/content/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/index.xml,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- index.xml	17 Aug 2004 12:33:22 -0000	1.16
  +++ index.xml	13 Sep 2004 14:48:16 -0000	1.17
  @@ -86,13 +86,9 @@
         code highly testable without a special container. </p>
   		<section>
   			<title>Status</title>
  -			<p>HiveMind has been promoted to a top-level <link
  -				href="http://jakarta.apache.org">Jakarta</link> project.</p>
  -			<p>Integration with &Spring; is now available as
  -				<link href="site:hivemind.lib.SpringLookupFactory">SpringLookupFactory</link>.</p>
  -      <p>The powerful new <link href="site:hivemind.lib.PipelineFactory">PipelineFactory</link>
  -        has been added.</p>
           <p>HiveMind now requires Ant 1.6.<strong>2</strong> to build.</p>
  +        <p>James Carman has just been voted on as a HiveMind committer.</p>
  +        <p>HiveMind is very close to a final 1.0 release, and work on a 1.1 release
is already underway.</p>
   		</section>
   		<section>
   			<title>Acknowledgments</title>
  
  
  
  1.2       +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.2
  diff -u -r1.1 -r1.2
  --- TestClassFab.java	31 Aug 2004 20:02:14 -0000	1.1
  +++ TestClassFab.java	13 Sep 2004 14:48:16 -0000	1.2
  @@ -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.
       }
  +
   }
  
  
  
  1.6       +13 -11    jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java
  
  Index: ProxyBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ProxyBuilder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProxyBuilder.java	25 Jun 2004 20:19:59 -0000	1.5
  +++ ProxyBuilder.java	13 Sep 2004 14:48:16 -0000	1.6
  @@ -14,7 +14,6 @@
   
   package org.apache.hivemind.impl;
   
  -import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   
   import org.apache.hivemind.internal.Module;
  @@ -23,6 +22,7 @@
   import org.apache.hivemind.service.ClassFab;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.ClassFactory;
  +import org.apache.hivemind.service.MethodIterator;
   import org.apache.hivemind.service.MethodSignature;
   
   /**
  @@ -53,7 +53,11 @@
           ClassFactory factory =
               (ClassFactory) module.getService("hivemind.ClassFactory", ClassFactory.class);
   
  -        _classFab = factory.newClass(ClassFabUtils.generateClassName(type), Object.class,
module);
  +        _classFab =
  +            factory.newClass(
  +                ClassFabUtils.generateClassName(type),
  +                Object.class,
  +                module.getClassResolver().getClassLoader());
   
           _classFab.addInterface(_serviceInterface);
       }
  @@ -71,13 +75,13 @@
       public void addServiceMethods(String indirection)
       {
           BodyBuilder builder = new BodyBuilder();
  -        boolean toString = false;
   
  -        Method[] methods = _serviceInterface.getMethods();
  -        for (int i = 0; i < methods.length; i++)
  +        MethodIterator mi = new MethodIterator(_serviceInterface);
  +
  +        while (mi.hasNext())
           {
  -        	Method m = methods[i];
  -        	
  +            MethodSignature m = mi.next();
  +
               builder.clear();
               builder.begin();
               builder.add("return ($r) ");
  @@ -87,12 +91,10 @@
               builder.addln("($$);");
               builder.end();
   
  -            _classFab.addMethod(Modifier.PUBLIC, new MethodSignature(m), builder.toString());
  -
  -            toString |= ClassFabUtils.isToString(m);
  +            _classFab.addMethod(Modifier.PUBLIC, m, builder.toString());
           }
   
  -        if (!toString)
  +        if (!mi.getToString())
               ClassFabUtils.addToStringMethod(
                   _classFab,
                   "<"
  
  
  
  1.9       +13 -15    jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/EJBProxyFactory.java
  
  Index: EJBProxyFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/EJBProxyFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EJBProxyFactory.java	18 Aug 2004 23:20:11 -0000	1.8
  +++ EJBProxyFactory.java	13 Sep 2004 14:48:16 -0000	1.9
  @@ -15,7 +15,6 @@
   package org.apache.hivemind.lib.impl;
   
   import java.lang.reflect.Constructor;
  -import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.rmi.RemoteException;
   import java.util.List;
  @@ -31,6 +30,7 @@
   import org.apache.hivemind.service.ClassFab;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.ClassFactory;
  +import org.apache.hivemind.service.MethodIterator;
   import org.apache.hivemind.service.MethodSignature;
   
   /**
  @@ -70,7 +70,10 @@
           String proxyClassName = ClassFabUtils.generateClassName("EJBProxy");
   
           ClassFab classFab =
  -            _classFactory.newClass(proxyClassName, AbstractEJBProxy.class, invokingModule);
  +            _classFactory.newClass(
  +                proxyClassName,
  +                AbstractEJBProxy.class,
  +                invokingModule.getClassResolver().getClassLoader());
   
           classFab.addInterface(serviceInterface);
   
  @@ -149,27 +152,22 @@
           String serviceId,
           String jndiName)
       {
  -        Method[] methods = serviceInterface.getMethods();
  -        boolean toString = false;
  +        MethodIterator mi = new MethodIterator(serviceInterface);
   
  -        for (int i = 0; i < methods.length; i++)
  +        while (mi.hasNext())
           {
  -            Method m = methods[i];
  -
  -            addServiceMethod(classFab, m);
  -
  -            toString |= ClassFabUtils.isToString(m);
  +            addServiceMethod(classFab, mi.next());
           }
   
  -        if (!toString)
  +        if (!mi.getToString())
               addToStringMethod(classFab, serviceInterface, serviceId, jndiName);
       }
   
  -    private void addServiceMethod(ClassFab classFab, Method m)
  +    private void addServiceMethod(ClassFab classFab, MethodSignature sig)
       {
  -        String methodName = m.getName();
  +        String methodName = sig.getName();
   
  -        boolean isVoid = m.getReturnType().equals(Void.TYPE);
  +        boolean isVoid = sig.getReturnType().equals(Void.TYPE);
   
           BodyBuilder builder = new BodyBuilder();
   
  @@ -210,7 +208,7 @@
           builder.end(); // while
           builder.end();
   
  -        classFab.addMethod(Modifier.PUBLIC, new MethodSignature(m), builder.toString());
  +        classFab.addMethod(Modifier.PUBLIC, sig, builder.toString());
       }
   
       private void addToStringMethod(
  
  
  
  1.5       +5 -1      jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
  
  Index: ServicePropertyFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServicePropertyFactory.java	31 Aug 2004 20:02:14 -0000	1.4
  +++ ServicePropertyFactory.java	13 Sep 2004 14:48:16 -0000	1.5
  @@ -80,7 +80,11 @@
   
           String name = ClassFabUtils.generateClassName("ServicePropertyProxy");
   
  -        ClassFab cf = _classFactory.newClass(name, Object.class, invokingModule);
  +        ClassFab cf =
  +            _classFactory.newClass(
  +                name,
  +                Object.class,
  +                invokingModule.getClassResolver().getClassLoader());
   
           addInfrastructure(cf, targetService, serviceInterface, propertyName, readMethodName);
   
  
  
  
  1.4       +13 -18    jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/DefaultImplementationBuilderImpl.java
  
  Index: DefaultImplementationBuilderImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/impl/DefaultImplementationBuilderImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultImplementationBuilderImpl.java	12 Jun 2004 18:43:41 -0000	1.3
  +++ DefaultImplementationBuilderImpl.java	13 Sep 2004 14:48:16 -0000	1.4
  @@ -14,7 +14,6 @@
   
   package org.apache.hivemind.lib.impl;
   
  -import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.Collections;
   import java.util.HashMap;
  @@ -27,6 +26,7 @@
   import org.apache.hivemind.service.ClassFab;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.ClassFactory;
  +import org.apache.hivemind.service.MethodIterator;
   import org.apache.hivemind.service.MethodSignature;
   
   /**
  @@ -78,24 +78,19 @@
   
           String name = ClassFabUtils.generateClassName("DefaultImpl");
   
  -        ClassFab cf = _classFactory.newClass(name, Object.class, module);
  +        ClassFab cf =
  +            _classFactory.newClass(name, Object.class, module.getClassResolver().getClassLoader());
   
           cf.addInterface(interfaceType);
   
  -        boolean toString = false;
  +        MethodIterator mi = new MethodIterator(interfaceType);
   
  -        Method[] methods = interfaceType.getMethods();
  -
  -        for (int i = 0; i < methods.length; i++)
  +        while (mi.hasNext())
           {
  -            Method m = methods[i];
  -
  -            toString |= ClassFabUtils.isToString(m);
  -
  -            addMethod(cf, m);
  +            addMethod(cf, mi.next());
           }
   
  -        if (!toString)
  +        if (!mi.getToString())
               ClassFabUtils.addToStringMethod(
                   cf,
                   ImplMessages.defaultImplementationDescription(interfaceType));
  @@ -103,7 +98,7 @@
           return cf.createClass();
       }
   
  -    private void addMethod(ClassFab cf, Method m)
  +    private void addMethod(ClassFab cf, MethodSignature m)
       {
           StringBuffer body = new StringBuffer("{ ");
   
  @@ -111,18 +106,18 @@
   
           if (returnType != void.class)
           {
  -            body.append("return ");
  +            body.append("return");
   
               if (returnType.isPrimitive())
               {
                   if (returnType == boolean.class)
  -                    body.append("false");
  +                    body.append(" false");
                   else
  -                    body.append("0");
  +                    body.append(" 0");
               }
               else
               {
  -                body.append("null");
  +                body.append(" null");
               }
   
               body.append(";");
  @@ -130,7 +125,7 @@
   
           body.append(" }");
   
  -        cf.addMethod(Modifier.PUBLIC, new MethodSignature(m), body.toString());
  +        cf.addMethod(Modifier.PUBLIC, m, body.toString());
       }
   
       public void setClassFactory(ClassFactory factory)
  
  
  
  1.8       +13 -5     jakarta-hivemind/framework/src/java/org/apache/hivemind/util/PropertyUtils.java
  
  Index: PropertyUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/util/PropertyUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PropertyUtils.java	6 Aug 2004 17:03:31 -0000	1.7
  +++ PropertyUtils.java	13 Sep 2004 14:48:16 -0000	1.8
  @@ -93,11 +93,11 @@
           return a.getPropertyType(target, propertyName);
       }
   
  -	/**
  -	 * Returns the {@link PropertyAdaptor} for the given target object and property name.
  -	 * 
  -	 * @throws ApplicationRuntimeException if the property does not exist.
  -	 */
  +    /**
  +     * Returns the {@link PropertyAdaptor} for the given target object and property name.
  +     * 
  +     * @throws ApplicationRuntimeException if the property does not exist.
  +     */
       public static PropertyAdaptor getPropertyAdaptor(Object target, String propertyName)
       {
           ClassAdaptor a = getAdaptor(target);
  @@ -157,6 +157,14 @@
                   null,
                   ex);
           }
  +    }
  +
  +	/**
  +	 * Clears all cached information.
  +	 */
  +    public static synchronized void clearCache()
  +    {
  +        _classAdaptors.clear();
       }
   
   }
  
  
  
  1.3       +2 -0      jakarta-hivemind/hivebuild/dist.xml
  
  Index: dist.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/hivebuild/dist.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- dist.xml	21 Aug 2004 16:06:59 -0000	1.2
  +++ dist.xml	13 Sep 2004 14:48:16 -0000	1.3
  @@ -75,6 +75,8 @@
   		  	<include name="*.gz"/>
   		  </fileset>
   		</checksum>
  +    
  +    <announce message="You should sign the release files (in target/dist) using GPG
before invoking the install-dist target."/>
   	</target>
   
   	
  
  
  
  1.14      +5 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HiveMindTestCase.java	9 Sep 2004 16:06:45 -0000	1.13
  +++ HiveMindTestCase.java	13 Sep 2004 14:48:16 -0000	1.14
  @@ -35,6 +35,7 @@
   import org.apache.hivemind.impl.RegistryBuilder;
   import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.util.ClasspathResource;
  +import org.apache.hivemind.util.PropertyUtils;
   import org.apache.hivemind.util.URLResource;
   import org.apache.log4j.Level;
   import org.apache.log4j.LogManager;
  @@ -148,7 +149,8 @@
   
       /**
        * Removes the {@link StoreAppender} that may have been setup by
  -     * {@link #interceptLogging(String)}.
  +     * {@link #interceptLogging(String)}. Also, invokes
  +     * {@link org.apache.hivemind.util.PropertyUtils#clearCache()}.
        */
       protected void tearDown() throws Exception
       {
  @@ -163,6 +165,8 @@
               logger.setAdditivity(true);
               logger.removeAllAppenders();
           }
  +
  +        PropertyUtils.clearCache();
       }
   
       /**
  
  
  
  1.6       +1 -1      jakarta-hivemind/version.properties
  
  Index: version.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/version.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- version.properties	25 Aug 2004 22:42:24 -0000	1.5
  +++ version.properties	13 Sep 2004 14:48:16 -0000	1.6
  @@ -15,4 +15,4 @@
   # Version of project; incorporated into the names of
   # archives and distributions.
   
  -project.version=1.0-rc-2-snapshot
  \ No newline at end of file
  +project.version=1.1-alpha-1
  \ No newline at end of file
  
  
  
  1.59      +17 -3     jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- status.xml	9 Sep 2004 16:06:46 -0000	1.58
  +++ status.xml	13 Sep 2004 14:48:16 -0000	1.59
  @@ -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>
  @@ -37,7 +37,7 @@
         </action>
       </release>
   
  -    <release version="1.0-rc-2" date="unreleased">
  +   <release version="1.0-rc-2" date="Sep 11 2004">
         <action type="add" dev="HLS">
           Add method <code>getSymbolValue()</code> to RegistryInfrastructure
and Module
         </action>
  @@ -50,7 +50,21 @@
         <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" fixes-bug="HIVEMIND-49">
  +        Class loading issue inside Tomcat.
  +      </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-10" due-to="James Carman">
  +        Tweak HiveMind to work properly in a JavaWebStart application.
  +      </action>
  +      <action type="add" dev="HLS">
  +        Add <code>clearCache()</code> method to <code>PropertyUtils</code>.
  +      </action>
  +      <action type="update" dev="HLS">
  +        Change the API for <code>ClassFactory</code> to take a <code>ClassLoader</code>,
not a <code>Module</code>.
  +      </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-52">
  +        Handle duplicated methods in service interfaces, avoiding "attempt to redefine
method" errors.
  +      </action>
       </release>
     
       <release version="1.0-rc-1" date="Aug 25 2004">
  
  
  
  1.4       +6 -3      jakarta-hivemind/framework/src/java/org/apache/hivemind/service/ClassFactory.java
  
  Index: ClassFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/service/ClassFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassFactory.java	17 Jun 2004 15:16:14 -0000	1.3
  +++ ClassFactory.java	13 Sep 2004 14:48:16 -0000	1.4
  @@ -14,8 +14,6 @@
   
   package org.apache.hivemind.service;
   
  -import org.apache.hivemind.internal.Module;
  -
   /**
    * Service used when dynamically creating new classes.
    *
  @@ -27,7 +25,12 @@
   	 * Creates a {@link ClassFab} object for the given name; the new class
   	 * is a subclass of the indicated class.  The new class
   	 * is public and concrete.
  +	 * 
  +	 * @param name the full qualified name of the class to create
  +	 * @param superClass the parent class, which is often java.lang.Object
  +	 * @param classLoader the class loader to use when resolving classes (this is usually
  +	 * provided by the containing {@link org.apache.hivemind.internal.Module}.
   	 */
   	
  -	public ClassFab newClass(String name, Class superClass, Module module);
  +	public ClassFab newClass(String name, Class superClass, ClassLoader classLoader);
   }
  
  
  
  1.2       +96 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/service/MethodIterator.java
  
  
  
  
  1.2       +116 -0    jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestMethodIterator.java
  
  
  
  
  1.7       +15 -32    jakarta-hivemind/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java
  
  Index: TestPipelineAssembler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/pipeline/TestPipelineAssembler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestPipelineAssembler.java	18 Aug 2004 19:34:12 -0000	1.6
  +++ TestPipelineAssembler.java	13 Sep 2004 14:48:16 -0000	1.7
  @@ -179,14 +179,7 @@
   
           dib.setClassFactory(cf);
   
  -        MockControl moduleControl = newControl(Module.class);
  -        Module module = (Module) moduleControl.getMock();
  -
  -        module.getModuleId();
  -        moduleControl.setReturnValue("foo.bar");
  -
  -        module.getClassResolver();
  -        moduleControl.setReturnValue(new DefaultClassResolver());
  +        Module module = newModule();
   
           ErrorHandler eh = getErrorHandler();
           Log log = getLog();
  @@ -218,14 +211,7 @@
   
           dib.setClassFactory(cf);
   
  -        MockControl moduleControl = newControl(Module.class);
  -        Module module = (Module) moduleControl.getMock();
  -
  -        module.getModuleId();
  -        moduleControl.setReturnValue("foo.bar");
  -
  -        module.getClassResolver();
  -        moduleControl.setReturnValue(new DefaultClassResolver());
  +        Module module = newModule();
   
           PipelineAssembler pa =
               new PipelineAssembler(
  @@ -286,14 +272,7 @@
   
           dib.setClassFactory(cf);
   
  -        MockControl moduleControl = newControl(Module.class);
  -        Module module = (Module) moduleControl.getMock();
  -
  -        module.getModuleId();
  -        moduleControl.setReturnValue("foo.bar");
  -
  -        module.getClassResolver();
  -        moduleControl.setReturnValue(new DefaultClassResolver());
  +        Module module = newModule();
   
           PipelineFactory factory = new PipelineFactory();
           factory.setClassFactory(cf);
  @@ -337,14 +316,7 @@
   
           dib.setClassFactory(cf);
   
  -        MockControl moduleControl = newControl(Module.class);
  -        Module module = (Module) moduleControl.getMock();
  -
  -        module.getModuleId();
  -        moduleControl.setReturnValue("foo.bar");
  -
  -        module.getClassResolver();
  -        moduleControl.setReturnValue(new DefaultClassResolver());
  +        Module module = newModule();
   
           PipelineFactory factory = new PipelineFactory();
           factory.setClassFactory(cf);
  @@ -383,6 +355,17 @@
           assertEquals(18, s.run(9));
   
           verifyControls();
  +    }
  +
  +    private Module newModule()
  +    {
  +        MockControl control = newControl(Module.class);
  +        Module result = (Module) control.getMock();
  +
  +        result.getClassResolver();
  +        control.setReturnValue(new DefaultClassResolver());
  +
  +        return result;
       }
   
       /**
  
  
  
  1.4       +0 -3      jakarta-hivemind/library/src/test/org/apache/hivemind/lib/pipeline/TestBridgeBuilder.java
  
  Index: TestBridgeBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/pipeline/TestBridgeBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestBridgeBuilder.java	29 Jul 2004 13:18:52 -0000	1.3
  +++ TestBridgeBuilder.java	13 Sep 2004 14:48:16 -0000	1.4
  @@ -39,9 +39,6 @@
           MockControl control = newControl(Module.class);
           Module result = (Module) control.getMock();
   
  -        result.getModuleId();
  -        control.setReturnValue("foo.bar");
  -
           result.getClassResolver();
           control.setReturnValue(new DefaultClassResolver());
   
  
  
  
  1.6       +6 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java
  
  Index: SmartTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/SmartTranslator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SmartTranslator.java	10 Aug 2004 13:18:50 -0000	1.5
  +++ SmartTranslator.java	13 Sep 2004 14:48:17 -0000	1.6
  @@ -56,6 +56,12 @@
           String inputValue,
           Location location)
       {
  +    	// HIVEMIND-10: Inside JavaWebStart you (strangely) can't rely on
  +    	// a PropertyEditor for String (even though it is trivial).
  +    	
  +        if (propertyType.equals(String.class))
  +            return inputValue;
  +
           if (inputValue == null)
           {
               if (_default == null)
  
  
  
  1.6       +10 -0     jakarta-hivemind/framework/src/test/hivemind/test/rules/TestSmartTranslator.java
  
  Index: TestSmartTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/rules/TestSmartTranslator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestSmartTranslator.java	10 Aug 2004 13:18:50 -0000	1.5
  +++ TestSmartTranslator.java	13 Sep 2004 14:48:17 -0000	1.6
  @@ -14,6 +14,8 @@
   
   package hivemind.test.rules;
   
  +import java.beans.PropertyEditorManager;
  +
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.Location;
   import org.apache.hivemind.Registry;
  @@ -89,6 +91,14 @@
           assertEquals("Fluffy Puppies", result);
       }
   
  +    public void testStringWithNoEditor()
  +    {
  +        PropertyEditorManager.setEditorSearchPath( new String[] { "bogus.package" } );
  +        Translator t = new SmartTranslator();
  +        Object result = t.translate(null, String.class, "Fluffy Puppies", null);
  +        assertEquals("Fluffy Puppies", result);
  +    }
  +    
       public void testNoEditor()
       {
           Translator t = new SmartTranslator();
  
  
  
  1.8       +0 -3      jakarta-hivemind/library/src/test/hivemind/test/lib/TestDefaultImplementationBuilder.java
  
  Index: TestDefaultImplementationBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/test/hivemind/test/lib/TestDefaultImplementationBuilder.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestDefaultImplementationBuilder.java	19 Aug 2004 22:24:01 -0000	1.7
  +++ TestDefaultImplementationBuilder.java	13 Sep 2004 14:48:17 -0000	1.8
  @@ -53,9 +53,6 @@
           MockControl c = newControl(Module.class);
           _module = (Module) c.getMock();
   
  -        _module.getModuleId();
  -        c.setReturnValue("some.id");
  -
           _module.getClassResolver();
           c.setReturnValue(new DefaultClassResolver());
   
  
  
  
  1.4       +0 -3      jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
  
  Index: TestServicePropertyFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestServicePropertyFactory.java	31 Aug 2004 20:02:14 -0000	1.3
  +++ TestServicePropertyFactory.java	13 Sep 2004 14:48:17 -0000	1.4
  @@ -47,9 +47,6 @@
           MockControl c = newControl(Module.class);
           Module result = (Module) c.getMock();
   
  -        result.getModuleId();
  -        c.setReturnValue("test.module");
  -
           result.getClassResolver();
           c.setReturnValue(new DefaultClassResolver());
   
  
  
  
  1.3       +12 -14    jakarta-hivemind/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java
  
  Index: BridgeBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/pipeline/BridgeBuilder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BridgeBuilder.java	12 Jun 2004 18:43:41 -0000	1.2
  +++ BridgeBuilder.java	13 Sep 2004 14:48:17 -0000	1.3
  @@ -15,7 +15,6 @@
   package org.apache.hivemind.lib.pipeline;
   
   import java.lang.reflect.Constructor;
  -import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -28,6 +27,7 @@
   import org.apache.hivemind.service.ClassFab;
   import org.apache.hivemind.service.ClassFabUtils;
   import org.apache.hivemind.service.ClassFactory;
  +import org.apache.hivemind.service.MethodIterator;
   import org.apache.hivemind.service.MethodSignature;
   
   /**
  @@ -63,35 +63,33 @@
   
           String name = ClassFabUtils.generateClassName("PipelineBridge");
   
  -        _classFab = classFactory.newClass(name, Object.class, module);
  +        _classFab =
  +            classFactory.newClass(name, Object.class, module.getClassResolver().getClassLoader());
   
           _filterMethodAnalyzer = new FilterMethodAnalyzer(serviceInterface);
       }
   
       private void createClass()
       {
  -        boolean toStringMethodExists = false;
           List serviceMethods = new ArrayList();
           List filterMethods = new ArrayList();
   
           createInfrastructure();
   
  -        Method[] methods = _serviceInterface.getMethods();
  -        for (int i = 0; i < methods.length; i++)
  +        MethodIterator mi = new MethodIterator(_serviceInterface);
  +
  +        while (mi.hasNext())
           {
  -            Method m = methods[i];
  +            serviceMethods.add(mi.next());
  +        }
   
  -            toStringMethodExists |= ClassFabUtils.isToString(m);
  +        boolean toStringMethodExists = mi.getToString();
   
  -            serviceMethods.add(new MethodSignature(m));
  -        }
  +        mi = new MethodIterator(_filterInterface);
   
  -        methods = _filterInterface.getMethods();
  -        for (int i = 0; i < methods.length; i++)
  +        while (mi.hasNext())
           {
  -            Method m = methods[i];
  -
  -            filterMethods.add(new MethodSignature(m));
  +            filterMethods.add(mi.next());
           }
   
           while (!serviceMethods.isEmpty())
  
  
  

---------------------------------------------------------------------
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