geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject cvs commit: incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/reference ReferenceableManagerImpl.java
Date Tue, 01 Jun 2004 13:37:14 GMT
gdamour     2004/06/01 06:37:14

  Modified:    sandbox/messaging/src/java/org/apache/geronimo/messaging/io
                        StreamManagerImpl.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy
                        EndPointCallback.java
               sandbox/messaging/src/test/org/apache/geronimo/messaging
                        RequestTest.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging
                        Request.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging/reference
                        ReferenceableManagerImpl.java
  Log:
  Request supports now overloaded methods.
  
  Revision  Changes    Path
  1.3       +5 -4      incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/io/StreamManagerImpl.java
  
  Index: StreamManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/io/StreamManagerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StreamManagerImpl.java	27 May 2004 15:46:54 -0000	1.2
  +++ StreamManagerImpl.java	1 Jun 2004 13:37:14 -0000	1.3
  @@ -56,7 +56,7 @@
        * Null input stream identifier.
        */
       private static final ID NULL_INPUT_STREAM = new ID(null);
  -    
  +
       /**
        * Node owning this manager.
        */
  @@ -148,7 +148,8 @@
           ID streamID = (ID) anID;
           byte[] result = (byte[])
               sender.sendSyncRequest(
  -                new Request("retrieveLocalNext", new Object[] {anID}),
  +                new Request("retrieveLocalNext", new Class[] {Object.class},
  +                    new Object[] {anID}),
                   out, StreamManager.NAME, streamID.hostingNode); 
           return result;
       }
  
  
  
  1.2       +3 -2      incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointCallback.java
  
  Index: EndPointCallback.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointCallback.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EndPointCallback.java	20 May 2004 13:37:11 -0000	1.1
  +++ EndPointCallback.java	1 Jun 2004 13:37:14 -0000	1.2
  @@ -132,7 +132,8 @@
           }
           try {
               Object opaque = sender.sendSyncRequest(
  -                    new Request(arg1.getName(), arg2), out, id, targets);
  +                new Request(arg1.getName(), arg1.getParameterTypes(), arg2),
  +                    out, id, targets);
               return opaque;
           } catch (RuntimeException e) {
               Throwable nested = e.getCause();
  
  
  
  1.2       +5 -5      incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/RequestTest.java
  
  Index: RequestTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/RequestTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RequestTest.java	11 May 2004 12:06:41 -0000	1.1
  +++ RequestTest.java	1 Jun 2004 13:37:14 -0000	1.2
  @@ -35,7 +35,7 @@
       }
       
       public void testExecute0() throws Exception {
  -        Request request = new Request("getID", null);
  +        Request request = new Request("getID", null, null);
           request.setTarget(target);
           Result result = request.execute();
           assertTrue(result.isSuccess());
  @@ -43,7 +43,7 @@
       }
       
       public void testExecute1() throws Exception {
  -        Request request = new Request("doesNotExist", null);
  +        Request request = new Request("doesNotExist", null, null);
           request.setTarget(target);
           Result result = request.execute();
           assertFalse(result.isSuccess());
  @@ -51,7 +51,7 @@
       }
       
       public void testExecute2() throws Exception {
  -        Request request = new Request("raiseISException", null);
  +        Request request = new Request("raiseISException", null, null);
           request.setTarget(target);
           Result result = request.execute();
           assertFalse(result.isSuccess());
  @@ -73,5 +73,5 @@
               throw new IOException();
           }
       }
  -    
  +
   }
  
  
  
  1.2       +26 -17    incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/Request.java
  
  Index: Request.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/Request.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Request.java	11 May 2004 12:06:41 -0000	1.1
  +++ Request.java	1 Jun 2004 13:37:14 -0000	1.2
  @@ -44,6 +44,11 @@
       private String methodName;
       
       /**
  +     * Method formal parameters.
  +     */
  +    private Class[] parameterTypes;
  +    
  +    /**
        * Parameters of methodName. 
        */
       private Object[] parameters;
  @@ -57,10 +62,13 @@
        * Wraps a method having the specified name and parameters.
        * 
        * @param aMethodName Method name.
  +     * @param anArrOfParamTypes Method formal parameters.
        * @param anArrOfParams Parameters.
        */
  -    public Request(String aMethodName, Object[] anArrOfParams) {
  +    public Request(String aMethodName, Class[] anArrOfParamTypes,
  +        Object[] anArrOfParams) {
           methodName = aMethodName;
  +        parameterTypes = anArrOfParamTypes;
           parameters = anArrOfParams;
       }
       
  @@ -82,6 +90,15 @@
       }
   
       /**
  +     * Gets the formal parameter of the method wrapped by this instance. 
  +     * 
  +     * @return Formal parameters.
  +     */
  +    public Class[] getParameterTypes() {
  +        return parameterTypes;
  +    }
  +    
  +    /**
        * Gets the parameters of the method to be executed.
        * 
        * @return Returns the parameters.
  @@ -99,36 +116,28 @@
        */
       public Result execute() {
           Class clazz = target.getClass();
  -        Method[] methods = clazz.getMethods();
  -        for (int i = 0; i < methods.length; i++) {
  -            Method method = methods[i];
  -            if ( method.getName().equals(methodName) ) {
  -                return invokeMethod(method);
  -            }
  -        }
  -        return new Result(false,
  -            new NoSuchMethodException("Method {" + methodName + 
  -                "} does not exist."));
  -    }
  -    
  -    private Result invokeMethod(Method aMethod) {
           try {
  -            Object opaque = aMethod.invoke(target, parameters);
  +            Method method = clazz.getMethod(methodName, parameterTypes);
  +            Object opaque = method.invoke(target, parameters);
               return new Result(true, opaque);
  +        } catch (NoSuchMethodException e) {
  +            return new Result(false, e);
           } catch (InvocationTargetException e) {
               return new Result(false, e.getCause());
           } catch (Throwable e) {
               return new Result(false, e);
           }
       }
  -
  +    
       public void writeExternal(ObjectOutput out) throws IOException {
           out.writeUTF(methodName);
  +        out.writeObject(parameterTypes);
           out.writeObject(parameters);
       }
   
       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
           methodName = in.readUTF();
  +        parameterTypes = (Class[]) in.readObject();
           parameters = (Object[]) in.readObject();
       }
   
  
  
  
  1.4       +3 -2      incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/reference/ReferenceableManagerImpl.java
  
  Index: ReferenceableManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/reference/ReferenceableManagerImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ReferenceableManagerImpl.java	27 May 2004 15:46:54 -0000	1.3
  +++ ReferenceableManagerImpl.java	1 Jun 2004 13:37:14 -0000	1.4
  @@ -17,6 +17,7 @@
   
   package org.apache.geronimo.messaging.reference;
   
  +import java.lang.reflect.Method;
   import java.util.HashMap;
   import java.util.IdentityHashMap;
   import java.util.Map;
  @@ -166,7 +167,7 @@
           }
           public void push(Msg aMsg) {
               Request request = 
  -                new Request("invoke",
  +                new Request("invoke", new Class[] {int.class, Request.class},
                       new Object[] {refID, aMsg.getBody().getContent()});
               aMsg.getBody().setContent(request);
               out.push(aMsg);
  
  
  

Mime
View raw message