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/framework/src/test/org/apache/hivemind/impl TestMethodIterator.java
Date Wed, 08 Sep 2004 17:18:10 GMT
hlship      2004/09/08 10:18:10

  Modified:    library/src/java/org/apache/hivemind/lib/impl Tag:
                        branch-1-0 EJBProxyFactory.java
                        DefaultImplementationBuilderImpl.java
               framework/src/java/org/apache/hivemind/impl Tag: branch-1-0
                        ProxyBuilder.java
               .        Tag: branch-1-0 status.xml
               framework/src/java/org/apache/hivemind/service/impl Tag:
                        branch-1-0 LoggingInterceptorFactory.java
               library/src/java/org/apache/hivemind/lib/pipeline Tag:
                        branch-1-0 BridgeBuilder.java
  Added:       framework/src/java/org/apache/hivemind/service Tag:
                        branch-1-0 MethodIterator.java
               framework/src/test/org/apache/hivemind/impl Tag: branch-1-0
                        TestMethodIterator.java
  Log:
  HIVEMIND-52: Handle duplicated methods in service interfaces, avoiding "attempt to redefine
method" errors.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.8.2.2   +9 -14     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.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- EJBProxyFactory.java	7 Sep 2004 19:38:27 -0000	1.8.2.1
  +++ EJBProxyFactory.java	8 Sep 2004 17:18:08 -0000	1.8.2.2
  @@ -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;
   
   /**
  @@ -152,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();
   
  @@ -213,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.3.2.2   +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.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- DefaultImplementationBuilderImpl.java	7 Sep 2004 19:38:27 -0000	1.3.2.1
  +++ DefaultImplementationBuilderImpl.java	8 Sep 2004 17:18:08 -0000	1.3.2.2
  @@ -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.getClassResolver().getClassLoader());
  +        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)
  
  
  
  No                   revision
  No                   revision
  1.5.2.2   +7 -9      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.2.1
  retrieving revision 1.5.2.2
  diff -u -r1.5.2.1 -r1.5.2.2
  --- ProxyBuilder.java	7 Sep 2004 19:38:27 -0000	1.5.2.1
  +++ ProxyBuilder.java	8 Sep 2004 17:18:09 -0000	1.5.2.2
  @@ -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;
   
   /**
  @@ -75,12 +75,12 @@
       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();
  @@ -91,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,
                   "<"
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +93 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/service/Attic/MethodIterator.java
  
  
  
  
  No                   revision
  No                   revision
  1.57.2.6  +3 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.57.2.5
  retrieving revision 1.57.2.6
  diff -u -r1.57.2.5 -r1.57.2.6
  --- status.xml	7 Sep 2004 19:38:28 -0000	1.57.2.5
  +++ status.xml	8 Sep 2004 17:18:09 -0000	1.57.2.6
  @@ -55,6 +55,9 @@
         <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">
  
  
  
  No                   revision
  No                   revision
  1.8.2.2   +6 -10     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.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- LoggingInterceptorFactory.java	7 Sep 2004 19:38:27 -0000	1.8.2.1
  +++ LoggingInterceptorFactory.java	8 Sep 2004 17:18:09 -0000	1.8.2.2
  @@ -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);
       }
   
  
  
  
  No                   revision
  No                   revision
  1.2.2.2   +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.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- BridgeBuilder.java	7 Sep 2004 19:38:28 -0000	1.2.2.1
  +++ BridgeBuilder.java	8 Sep 2004 17:18:09 -0000	1.2.2.2
  @@ -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.getClassResolver().getClassLoader());
  +        _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())
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +112 -0    jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/Attic/TestMethodIterator.java
  
  
  
  

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