avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vin...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator BCELProxyGeneratorTestCase.java TestInvocationHandler.java
Date Wed, 04 Sep 2002 11:01:23 GMT
vinayc      2002/09/04 04:01:23

  Modified:    altrmi/src/java/org/apache/excalibur/altrmi/client
                        AltrmiClientInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl
                        AbstractAltrmiFactory.java
                        AbstractClientInvocationHandler.java
                        DefaultProxyHelper.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket
                        CallbackEnabledSocketCustomStreamInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple
                        AbstractMultipleInvocationHandler.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/generator
                        BCELProxyGeneratorTestCase.java
                        TestInvocationHandler.java
  Log:
  Refactoring callbacks (proxyHelper is dis-infected with callback specific calls)
  Extra handling of marshalling can now be done at the transport's
  invocation handler.
  
  Revision  Changes    Path
  1.5       +10 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/AltrmiClientInvocationHandler.java
  
  Index: AltrmiClientInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/AltrmiClientInvocationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AltrmiClientInvocationHandler.java	6 May 2002 18:14:36 -0000	1.4
  +++ AltrmiClientInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.5
  @@ -78,5 +78,14 @@
        *
        */
       ClassLoader getInterfacesClassLoader();
  +    
  +    /**
  +     * morphObject handles any changes  to the arguments being
  +     * marshalled to the server.
  +     * @param inputArgumentClass Class of the input argument
  +     * @param obj instance of the object being marshalled to the server
  +     * @return Object new object that replaces the input argument.
  +     */
   
  +    public Object resolveArgument(String methodSignature,Class inputArgumentClass, Object
inputArgumentInstance);
   }
  
  
  
  1.8       +52 -2     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java
  
  Index: AbstractAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractAltrmiFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AbstractAltrmiFactory.java	23 May 2002 21:37:19 -0000	1.7
  +++ AbstractAltrmiFactory.java	4 Sep 2002 11:01:23 -0000	1.8
  @@ -10,13 +10,16 @@
   import java.io.IOException;
   import java.lang.ref.WeakReference;
   import java.util.HashMap;
  +
   import org.apache.excalibur.altrmi.client.AltrmiFactory;
   import org.apache.excalibur.altrmi.client.AltrmiHostContext;
   import org.apache.excalibur.altrmi.client.AltrmiProxy;
   import org.apache.excalibur.altrmi.common.AltrmiAuthentication;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
  +import org.apache.excalibur.altrmi.common.AltrmiReplyConstants;
   import org.apache.excalibur.altrmi.common.ExceptionReply;
  +import org.apache.excalibur.altrmi.common.FacadeRefHolder;
   import org.apache.excalibur.altrmi.common.ListReply;
   import org.apache.excalibur.altrmi.common.ListRequest;
   import org.apache.excalibur.altrmi.common.LookupReply;
  @@ -24,7 +27,6 @@
   import org.apache.excalibur.altrmi.common.NotPublishedReply;
   import org.apache.excalibur.altrmi.common.OpenConnectionReply;
   import org.apache.excalibur.altrmi.common.OpenConnectionRequest;
  -import org.apache.excalibur.altrmi.common.AltrmiReplyConstants;
   
   /**
    * Class AbstractAltrmiFactory
  @@ -309,4 +311,52 @@
               };
           }
       }
  +    
  +    
  +    /**
  +     * Wraps the reference to the remote obj within the FacadeRefHolder obj.
  +     * @param obj
  +     * @param objectName
  +     * @return
  +     */
  +    private FacadeRefHolder makeFacadeRefHolder( AltrmiProxy obj, String objectName )
  +    {
  +
  +        Long refID = getReferenceID( obj );
  +
  +        return new FacadeRefHolder( refID, objectName );
  +    }
  +    
  +
  +    
  +       
  +    public void marshallCorrection( String methodSignature, Object[] args, Class[] argClasses
)
  +    {
  +
  +        for( int i = 0; i < args.length; i++ )
  +        {
  +            Class argClass = argClasses[ i ];
  +            if(argClass==null)
  +                continue;
  +            //All remote references implement AltrmiProxy interface
  +            if(args[i] instanceof AltrmiProxy)
  +            {
  +                AltrmiProxy proxy = (AltrmiProxy)args[i];
  +    
  +                    if( getReferenceID( proxy ) != null )
  +                    {
  +                        //The stripping "AltrmiGenerated2" from the proxy names generated
by
  +                        //ProxyGenerator's:- "AltrmiGenerated2".length()=16
  +                        String objName = args[i].getClass().getName().substring( 16 );
  +    
  +                        args[i]= makeFacadeRefHolder( proxy, objName );
  +                    }
  +            }
  +            else // Let the specific InvocationHandlers be given the last chance to modify
the arguments.
  +            {
  +                args[i]=mHostContext.getClientInvocationHandler().resolveArgument(methodSignature,argClasses[i],args[i]);
  +            }
  +        }
  +    }
  +    
   }
  
  
  
  1.4       +19 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractClientInvocationHandler.java
  
  Index: AbstractClientInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/AbstractClientInvocationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractClientInvocationHandler.java	24 Apr 2002 12:42:56 -0000	1.3
  +++ AbstractClientInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.4
  @@ -8,12 +8,15 @@
   package org.apache.excalibur.altrmi.client.impl;
   
   import java.io.IOException;
  +
   import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
   import org.apache.excalibur.altrmi.client.AltrmiConnectionListener;
   import org.apache.excalibur.altrmi.client.AltrmiConnectionPinger;
  +import org.apache.excalibur.altrmi.client.AltrmiProxy;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionClosedException;
   import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
  +import org.apache.excalibur.altrmi.common.FacadeRefHolder;
   import org.apache.excalibur.altrmi.common.PingRequest;
   
   /**
  @@ -117,4 +120,19 @@
       {
           return AbstractClientInvocationHandler.class.getClassLoader();
       }
  +    
  +    
  +    /**
  +     * resolveArgument can handle any changes that one has to  do to the arguments being
  +     * marshalled to the server.
  +     * Noop Default behaviour.
  +     * @param objClass
  +     * @param obj
  +     * @return Object
  +     */
  +
  +    public Object resolveArgument(String methodSignature ,Class objClass , Object obj)
  +    {
  +        return obj;
  +    } 
   }
  
  
  
  1.12      +6 -100    jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultProxyHelper.java
  
  Index: DefaultProxyHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/DefaultProxyHelper.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultProxyHelper.java	26 Aug 2002 10:44:08 -0000	1.11
  +++ DefaultProxyHelper.java	4 Sep 2002 11:01:23 -0000	1.12
  @@ -8,19 +8,14 @@
   package org.apache.excalibur.altrmi.client.impl;
   
   import java.lang.reflect.Array;
  -import java.io.IOException;
   
  +import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
   import org.apache.excalibur.altrmi.client.AltrmiProxy;
   import org.apache.excalibur.altrmi.client.ProxyHelper;
  -import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler;
  -import org.apache.excalibur.altrmi.client.CallbackEnabledClientInvocationHandler;
  -import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
   import org.apache.excalibur.altrmi.common.AltrmiInvocationException;
  -import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
  +import org.apache.excalibur.altrmi.common.AltrmiReplyConstants;
   import org.apache.excalibur.altrmi.common.ExceptionReply;
  -import org.apache.excalibur.altrmi.common.ExposedObjectProxy;
  -import org.apache.excalibur.altrmi.common.FacadeRefHolder;
   import org.apache.excalibur.altrmi.common.GarbageCollectionReply;
   import org.apache.excalibur.altrmi.common.GarbageCollectionRequest;
   import org.apache.excalibur.altrmi.common.MethodFacadeArrayReply;
  @@ -28,7 +23,6 @@
   import org.apache.excalibur.altrmi.common.MethodFacadeRequest;
   import org.apache.excalibur.altrmi.common.MethodReply;
   import org.apache.excalibur.altrmi.common.MethodRequest;
  -import org.apache.excalibur.altrmi.common.AltrmiReplyConstants;
   
   /**
    * Class DefaultProxyHelper
  @@ -48,10 +42,6 @@
       private final transient Long mReferenceID;
       private final transient Long mSession;
   
  -    //<callback related>
  -    private boolean mIsCallbackAware = false;
  -
  -    //</callback related>
   
       /**
        * Constructor DefaultProxyHelper
  @@ -77,14 +67,6 @@
           mObjectName = objectName;
           mReferenceID = referenceID;
           mSession = session;
  -
  -        //<callback related>
  -        if( mClientInvocationHandler instanceof CallbackEnabledClientInvocationHandler
)
  -        {
  -            mIsCallbackAware = true;
  -        }
  -
  -        //</callback related>
       }
   
       /**
  @@ -252,7 +234,7 @@
       public Object processObjectRequest( String methodSignature, Object[] args, Class[]
argClasses ) throws Throwable
       {
   
  -        marshallCorrection( methodSignature, args, argClasses );
  +        mAltrmiFactory.marshallCorrection( methodSignature, args, argClasses );
   
           MethodRequest request = new MethodRequest( mPublishedServiceName, mObjectName,
                                                      methodSignature, args, mReferenceID,
mSession );
  @@ -347,23 +329,7 @@
           processVoidRequest( methodSignature, newArgs );
       }
   
  -    /**
  -     * Method makeFacadeRefHolder
  -     *
  -     *
  -     * @param obj
  -     * @param objectName
  -     *
  -     * @return
  -     *
  -     */
  -    public FacadeRefHolder makeFacadeRefHolder( AltrmiProxy obj, String objectName )
  -    {
  -
  -        Long refID = mAltrmiFactory.getReferenceID( obj );
  -
  -        return new FacadeRefHolder( refID, objectName );
  -    }
  +    
   
       private void debug( Object[] args )
       {
  @@ -377,67 +343,7 @@
           }
       }
   
  -    private void marshallCorrection( String methodSignature, Object[] args, Class[] argClasses
)
  -    {
  -
  -        for( int i = 0; i < args.length; i++ )
  -        {
  -            Class argClass = argClasses[ i ];
  -
  -            //check whether its one of those remote ref that we got from the server
  -            //TODO : todo
  -            if( argClass != null && args[ i ] instanceof AltrmiProxy )
  -            {
  -                AltrmiProxy proxy = (AltrmiProxy)args[ i ];
  -
  -                if( mAltrmiFactory.getReferenceID( proxy ) != null )
  -                {
  -                    String objName = args[ i ].getClass().getName().substring( 16 );
  -
  -                    args[ i ] = makeFacadeRefHolder( proxy, objName );
  -                }
  -            }
  -            else if( argClass != null && mIsCallbackAware )
  -            {
  -                String publishedName =
  -                    ((CallbackEnabledClientInvocationHandler) mClientInvocationHandler).getPublishedName(
args[ i ] );
  -
  -                if( publishedName != null )            //already published
  -                {
  -                    ExposedObjectProxy exposedObjectProxy = new ExposedObjectProxy( publishedName
);
  -
  -                    args[ i ] = exposedObjectProxy;
  -                }
  -                else                                  //check whether its Publish'able
  -                {
  -                    if( !argClass.isInterface() )    //Hey do we handle only interfaces?
  -                    {
  -                        continue;
  -                    }
  -
  -                    if( argClass.isAssignableFrom( args[ i ].getClass() ) )
  -                    {
  -                        try
  -                        {
  -                            ((CallbackEnabledClientInvocationHandler) mClientInvocationHandler).exposeObject(
args[ i ], argClass );
  -                        }
  -                        catch( AltrmiCallbackException ace )
  -                        {
  -                            ace.printStackTrace();
  -                        }
  -
  -                        publishedName =
  -                            ((CallbackEnabledClientInvocationHandler) mClientInvocationHandler).getPublishedName(
args[ i ] );
  -
  -                        ExposedObjectProxy exposedObjectProxy =
  -                            new ExposedObjectProxy( publishedName );
  -
  -                        args[ i ] = exposedObjectProxy;
  -                    }
  -                }
  -            }
  -        }
  -    }
  +    
   
       /**
        * Method getReferenceID
  
  
  
  1.6       +65 -2     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java
  
  Index: CallbackEnabledSocketCustomStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CallbackEnabledSocketCustomStreamInvocationHandler.java	6 May 2002 18:14:36 -0000	1.5
  +++ CallbackEnabledSocketCustomStreamInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.6
  @@ -10,12 +10,14 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +
  +import org.apache.excalibur.altrmi.client.CallbackEnabledClientInvocationHandler;
   import org.apache.excalibur.altrmi.client.impl.callback.stream.CallbackEnabledClientCustomStreamReadWriter;
   import org.apache.excalibur.altrmi.client.impl.socket.AbstractSocketStreamInvocationHandler;
   import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
  -import org.apache.excalibur.altrmi.client.CallbackEnabledClientInvocationHandler;
   import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  +import org.apache.excalibur.altrmi.common.ExposedObjectProxy;
   
   /**
    * Class CallbackEnabledSocketCustomStreamInvocationHandler
  @@ -60,6 +62,67 @@
       {
           return mCallbackEnabledClientCustomStreamReadWriter.getPublishedName( tobeExposedObject
);
       }
  +
  +    
  +
  +
  +    /**
  +     * <pre>
  +     * <code>resolveArgument</code> override here handles the passage of references

  +     * of client to the server ,so that the server
  +     * can issue callbacks back to the client using 
  +     * those references.
  +     * </pre>
  +     * @see org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler#resolveArgument(String,
Class, Object)
  +     */
  +    public Object resolveArgument(
  +        String methodSignature,
  +        Class inputArgumentClass,
  +        Object inputArgumentInstance)
  +    {
  +  
  +        System.out.println("callback class["+inputArgumentClass+"] obj["+inputArgumentInstance+"]");

  +        if( inputArgumentClass != null)
  +        {
  +            String publishedName =getPublishedName( inputArgumentInstance );
  +
  +            if( publishedName != null )            //already published
  +            {
  +                ExposedObjectProxy exposedObjectProxy = new ExposedObjectProxy( publishedName
);
  +
  +                inputArgumentInstance= exposedObjectProxy;
  +            }
  +            else                                  //check whether its Publish'able
  +            {
  +                if( !inputArgumentClass.isInterface() )    //We handle only Interface's
to be exposed
  +                {
  +                    return inputArgumentInstance;
  +                }
  +
  +                if( inputArgumentClass.isAssignableFrom( inputArgumentInstance.getClass()
) )
  +                {
  +                    try
  +                    {
  +                        exposeObject( inputArgumentInstance, inputArgumentClass );
  +                    }
  +                    catch( AltrmiCallbackException ace )
  +                    {
  +                        ace.printStackTrace();
  +                    }
  +
  +                    ExposedObjectProxy exposedObjectProxy =
  +                        new ExposedObjectProxy( getPublishedName( inputArgumentInstance
) );
  +
  +                    inputArgumentInstance =exposedObjectProxy;
  +                }
  +            }
  +        }
  +        
  +        return inputArgumentInstance;
  +    }
  +    
  +    
  +
   
   }
   
  
  
  
  1.3       +15 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple/AbstractMultipleInvocationHandler.java
  
  Index: AbstractMultipleInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/multiple/AbstractMultipleInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractMultipleInvocationHandler.java	24 Apr 2002 12:42:57 -0000	1.2
  +++ AbstractMultipleInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.3
  @@ -105,4 +105,18 @@
       {
           return null;    //TODO
       }
  +    /**
  +     * resolveArgument can handle any changes that one has to  do to the arguments being
  +     * marshalled to the server.
  +     * Noop Default behaviour.
  +     * @param objClass
  +     * @param obj
  +     * @return Object
  +     */
  +
  +    public Object resolveArgument(String methodSignature ,Class objClass , Object obj)
  +    {
  +        return obj;
  +    } 
  +    
   }
  
  
  
  1.4       +10 -4     jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/BCELProxyGeneratorTestCase.java
  
  Index: BCELProxyGeneratorTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/BCELProxyGeneratorTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BCELProxyGeneratorTestCase.java	23 May 2002 21:37:21 -0000	1.3
  +++ BCELProxyGeneratorTestCase.java	4 Sep 2002 11:01:23 -0000	1.4
  @@ -14,6 +14,8 @@
   import junit.framework.TestCase;
   
   import org.apache.excalibur.altrmi.client.impl.DefaultProxyHelper;
  +import org.apache.excalibur.altrmi.client.impl.direct.DirectHostContext;
  +import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
   import org.apache.excalibur.altrmi.common.ProxyGenerator;
   import org.apache.excalibur.altrmi.generator.BCELProxyGeneratorImpl;
   
  @@ -30,6 +32,7 @@
       private ProxyGenerator mProxyGenerator;
       private Class mGeneratedProxyClass;
       private Object mGeneratedProxyObject; 
  +	private ClientClassAltrmiFactory mAltrmiFactory;
       /************************ TestInterface *******************/
       public  static final Class mTestInterfaceClass=//org.apache.excalibur.altrmi.test.TestInterface.class;
                                                        TestRemoteInterface.class;
  @@ -76,6 +79,8 @@
           //create the Proxy Class using the BCEL Generator
           _createNewClass();    
           mProxyGenerator.verbose(true);
  +		//create the factory;
  +		mAltrmiFactory=new ClientClassAltrmiFactory(false);
       }
       
       
  @@ -100,10 +105,11 @@
       {
           if(mGeneratedProxyClass==null)
               testGeneratedClassNameOfProxy();
  -        
  +        TestInvocationHandler invocationHandler =new TestInvocationHandler();
  +		mAltrmiFactory.setHostContext(new DirectHostContext(invocationHandler));
           DefaultProxyHelper defaultProxyHelper = 
  -                            new DefaultProxyHelper(null,
  -                                                  new TestInvocationHandler(),
  +                            new DefaultProxyHelper(mAltrmiFactory,
  +                                                  invocationHandler,
                                                     "PublishedName",
                                                     "ObjectName",
                                                     new Long(1010),
  @@ -137,7 +143,7 @@
           
           Method _getReferenceIDMethod = mGeneratedProxyClass.getMethod("altrmiGetReferenceID",new
Class[]{Object.class});
           assertNotNull(_getReferenceIDMethod);
  -        Object _ret = _getReferenceIDMethod.invoke(mGeneratedProxyObject,new Object[]{null});
  +        Object _ret = _getReferenceIDMethod.invoke(mGeneratedProxyObject,new Object[]{mAltrmiFactory});
           assertEquals(new Long(1010),_ret);
       }
   
  
  
  
  1.5       +38 -29    jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/TestInvocationHandler.java
  
  Index: TestInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/generator/TestInvocationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestInvocationHandler.java	23 May 2002 21:37:21 -0000	1.4
  +++ TestInvocationHandler.java	4 Sep 2002 11:01:23 -0000	1.5
  @@ -10,13 +10,14 @@
   
   import java.lang.reflect.Method;
   
  -import org.apache.excalibur.altrmi.common.AltrmiInvocationHandler;
  +import org.apache.excalibur.altrmi.client.impl.AbstractClientInvocationHandler;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
   import org.apache.excalibur.altrmi.common.AltrmiRequest;
   import org.apache.excalibur.altrmi.common.ExceptionReply;
   import org.apache.excalibur.altrmi.common.MethodReply;
   import org.apache.excalibur.altrmi.common.MethodRequest;
  -import org.apache.excalibur.altrmi.client.impl.AbstractClientInvocationHandler;
  +import org.apache.excalibur.altrmi.common.OpenConnectionReply;
  +import org.apache.excalibur.altrmi.common.OpenConnectionRequest;
   
   /**
    * TestInvocationHandler 
  @@ -29,39 +30,47 @@
        * @see AltrmiInvocationHandler#handleInvocation(AltrmiRequest)
        */
       public AltrmiReply handleInvocation(AltrmiRequest request) {
  -        MethodRequest methodRequest = (MethodRequest) request;
  -        //System.out.println("methodRequest[" + methodRequest.getMethodSignature() + "]");
  -        Method[] methods = TestRemoteInterface.class.getMethods();
  -        for (int i = 0; i < methods.length; i++) 
  +        if(request instanceof OpenConnectionRequest)
           {
  -            try
  +            return new OpenConnectionReply();
  +        }
  +        else if(request instanceof MethodRequest)
  +        {
  +            MethodRequest methodRequest = (MethodRequest) request;
  +            //System.out.println("methodRequest[" + methodRequest.getMethodSignature()
+ "]");
  +            Method[] methods = TestRemoteInterface.class.getMethods();
  +            for (int i = 0; i < methods.length; i++) 
               {
  -                if (methodRequest.getMethodSignature().indexOf(methods[i].getName()) !=
-1)
  +                try
                   {
  -                    Object[] _arguments=methodRequest.getArgs();
  -                    for(int j=0;j<_arguments.length;j++)
  -                    {    
  -                        
  -                        if(!TestRemoteInterface.class.getField(methods[i].getName() + "_arg"+j).get(null).equals(_arguments[j]))
  -                        {
  -                            return new ExceptionReply(new Exception(methodRequest.getMethodSignature()+":
arguments not marshalled correctly \n expected["+TestRemoteInterface.class.getField(methods[i].getName()
+ "_arg"+j).get(null)+"] received["+_arguments[j]+"]"));
  +                    if (methodRequest.getMethodSignature().indexOf(methods[i].getName())
!= -1)
  +                    {
  +                        Object[] _arguments=methodRequest.getArgs();
  +                        for(int j=0;j<_arguments.length;j++)
  +                        {    
  +                            
  +                            if(!TestRemoteInterface.class.getField(methods[i].getName()
+ "_arg"+j).get(null).equals(_arguments[j]))
  +                            {
  +                                return new ExceptionReply(new Exception(methodRequest.getMethodSignature()+":
arguments not marshalled correctly \n expected["+TestRemoteInterface.class.getField(methods[i].getName()
+ "_arg"+j).get(null)+"] received["+_arguments[j]+"]"));
  +                            }
                           }
  +                        MethodReply methodReply =null;
  +                        if(methods[i].getReturnType()!=Void.TYPE)
  +                        
  +                            methodReply =
  +                                new MethodReply(
  +                                    TestRemoteInterface.class.getField(methods[i].getName()
+ "_retValue").get(null));
  +                        else
  +                            methodReply =new MethodReply();                
  +                        return methodReply;
                       }
  -                    MethodReply methodReply =null;
  -                    if(methods[i].getReturnType()!=Void.TYPE)
  -                    
  -                        methodReply =
  -                            new MethodReply(
  -                                TestRemoteInterface.class.getField(methods[i].getName()
+ "_retValue").get(null));
  -                    else
  -                        methodReply =new MethodReply();                
  -                    return methodReply;
                   }
  -            }
  -            catch(Exception e)
  -            {
  -                e.printStackTrace();
  -                return new ExceptionReply(e);
  +                catch(Exception e)
  +                {
  +                    e.printStackTrace();
  +                    return new ExceptionReply(e);
  +                }
  +            
               }
           }
           return null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message