avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback CallBackTestClient.java CallBackTestServer.java
Date Wed, 10 Apr 2002 22:33:11 GMT
hammant     02/04/10 15:33:11

  Modified:    altrmi   callback.xml
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl
                        BaseServedObject.java ServerClassAltrmiFactory.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream
                        ClientStreamReadWriter.java
               altrmi/src/java/org/apache/excalibur/altrmi/common
                        ClassRetrievalFailedReply.java
               altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters
                        InvocationHandlerAdapter.java
               altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers
                        PlainClassRetriever.java
               altrmi/src/test/org/apache/excalibur/altrmi/test/callback
                        CallBackTestClient.java CallBackTestServer.java
  Log:
  Callback's enabled - first cut courtesy of Vinay.
  
  Revision  Changes    Path
  1.3       +11 -2     jakarta-avalon-excalibur/altrmi/callback.xml
  
  Index: callback.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/callback.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- callback.xml	8 Apr 2002 20:24:23 -0000	1.2
  +++ callback.xml	10 Apr 2002 22:33:10 -0000	1.3
  @@ -56,11 +56,20 @@
         <classpath>
           <pathelement location="${build.home}/classes"/>
         </classpath>
  -    </altrmiproxies>        
  +    </altrmiproxies>    
  +    
  +    <altrmiproxies genname="CallBackTestListenerImpl" srcgendir="${build.home}/genjava"

  +        classgendir="${build.home}/genclasses" verbose="true" 
  +        interfaces="org.apache.excalibur.altrmi.test.callback.CallBackTestListener">
  +      <classpath>
  +        <pathelement location="${build.home}/classes"/>
  +      </classpath>
  +    </altrmiproxies>     
  +    
     
     </target>
   
  -  <target name="server" description="Callback test server">
  +  <target name="server" depends="generate" description="Callback test server">
     
       <echo>Warning : This spawns a seperate process that is not killed by Ctrl-C on
this process</echo>
     
  
  
  
  1.2       +66 -4     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/BaseServedObject.java
  
  Index: BaseServedObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/BaseServedObject.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseServedObject.java	3 Apr 2002 11:29:50 -0000	1.1
  +++ BaseServedObject.java	10 Apr 2002 22:33:10 -0000	1.2
  @@ -27,6 +27,11 @@
   
   import java.lang.reflect.Array;
   
  +//callback
  +import org.apache.excalibur.altrmi.common.ExposedObjectProxy;
  +import org.apache.excalibur.altrmi.client.impl.socket.CallbackEnabledCustomSocketStreamInvocationHandler;
  +import java.util.StringTokenizer;
  +import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
   
   /**
    * Class BaseServedObject
  @@ -34,7 +39,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class BaseServedObject {
   
  @@ -44,7 +49,10 @@
       private final transient String mObjectName;
       private final transient Long mReferenceID;
       private final transient Long mSession;
  -
  +	//<callback related>
  +	private boolean mbIsCallbackAware=false;
  +	private CallbackEnabledCustomSocketStreamInvocationHandler mCallbackEnabledCustomSocketStreamInvocationHandler=null;
  +	//</callback related>
       /**
        * Constructor BaseServedObject
        *
  @@ -68,6 +76,15 @@
           mObjectName = objectName;
           mReferenceID = referenceID;
           mSession = session;
  +        //<callback related>
  +        if(mInvocationHandler instanceof CallbackEnabledCustomSocketStreamInvocationHandler)
  +		{
  +			
  +			mCallbackEnabledCustomSocketStreamInvocationHandler	=
  +				(CallbackEnabledCustomSocketStreamInvocationHandler)mInvocationHandler;
  +			mbIsCallbackAware=true;
  +		}
  +        //</callback related>		
       }
   
       /**
  @@ -203,7 +220,7 @@
        */
       public Object processObjectRequest(String methodSignature, Object[] args) throws Throwable
{
   
  -        marshallCorrection(args);
  +        marshallCorrection(methodSignature,args);
   
           MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName,
                                                     methodSignature, args, mReferenceID,
mSession);
  @@ -309,9 +326,24 @@
           }
       }
   
  -    private void marshallCorrection(Object[] args) {
  +    private void marshallCorrection(String methodSignature , Object[] args) {
  +
  +		String _methodArgumentClasses = methodSignature.substring(methodSignature.indexOf("(")+1,methodSignature.lastIndexOf(")"));
  +		StringTokenizer _methodArgumentClassTokens = new StringTokenizer(_methodArgumentClasses,",");
   
           for (int i = 0; i < args.length; i++) {
  +			
  +			String _sArgClass=_methodArgumentClassTokens.nextToken();
  +			Class _cArgClass=null;
  +			try
  +			{
  +
  +				_cArgClass=Class.forName(_sArgClass);
  +			}
  +			catch(ClassNotFoundException cnfe)
  +			{
  +				System.err.println("Class "+_sArgClass +" Not Found");
  +			}
   
               //check whether its one of those remote ref that we got from the server
               //TODO : todo
  @@ -324,6 +356,36 @@
                       args[i] = makeFacadeRefHolder(proxy, objName);
                   }
               }
  +            else if(mbIsCallbackAware)
  +			{
  +				String publishedName = mCallbackEnabledCustomSocketStreamInvocationHandler.getPublishedName(args[i]);
  +				if(publishedName!=null) //already published
  +				{
  +					ExposedObjectProxy exposedObjectProxy =  new ExposedObjectProxy(publishedName);
  +					args[i]=exposedObjectProxy;
  +				}
  +				else //check whether its Publish'able
  +				{
  +					if(!_cArgClass.isInterface()) //Hey do we handle only interfaces?
  +						continue;
  +					if(_cArgClass.isAssignableFrom(args[i].getClass()))
  +					{
  +						try
  +						{
  +							mCallbackEnabledCustomSocketStreamInvocationHandler.exposeObject(args[i],_cArgClass);
  +						}
  +						catch(AltrmiCallbackException ace)
  +						{
  +							ace.printStackTrace();
  +						}
  +						publishedName = mCallbackEnabledCustomSocketStreamInvocationHandler.getPublishedName(args[i]);
  +						ExposedObjectProxy exposedObjectProxy =  new ExposedObjectProxy(publishedName);
  +						args[i]=exposedObjectProxy;
  +
  +					}
  +
  +				}
  +			}
           }
       }
   
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ServerClassAltrmiFactory.java
  
  Index: ServerClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ServerClassAltrmiFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerClassAltrmiFactory.java	3 Apr 2002 11:29:50 -0000	1.1
  +++ ServerClassAltrmiFactory.java	10 Apr 2002 22:33:10 -0000	1.2
  @@ -36,7 +36,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -130,7 +130,7 @@
                           } else if (ar instanceof ClassRetrievalFailedReply) {
                               ClassRetrievalFailedReply crfr = (ClassRetrievalFailedReply)
ar;
   
  -                            throw new AltrmiConnectionException("Exception on server side
");
  +                            throw new AltrmiConnectionException("Class Retrieval Failed
- " + crfr.getReason());
                           }    //TODO others.
                       }
   
  
  
  
  1.2       +0 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientStreamReadWriter.java
  
  Index: ClientStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientStreamReadWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClientStreamReadWriter.java	3 Apr 2002 11:29:52 -0000	1.1
  +++ ClientStreamReadWriter.java	10 Apr 2002 22:33:10 -0000	1.2
  @@ -13,8 +13,6 @@
   import org.apache.excalibur.altrmi.common.AltrmiRequest;
   import org.apache.excalibur.altrmi.common.AltrmiReply;
   
  -import java.io.InputStream;
  -import java.io.OutputStream;
   import java.io.IOException;
   
   
  @@ -23,7 +21,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class ClientStreamReadWriter
   {
  
  
  
  1.3       +57 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/ClassRetrievalFailedReply.java
  
  Index: ClassRetrievalFailedReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/ClassRetrievalFailedReply.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ClassRetrievalFailedReply.java	4 Apr 2002 12:53:03 -0000	1.2
  +++ ClassRetrievalFailedReply.java	10 Apr 2002 22:33:10 -0000	1.3
  @@ -8,6 +8,9 @@
    */
   package org.apache.excalibur.altrmi.common;
   
  +import java.io.ObjectOutput;
  +import java.io.IOException;
  +import java.io.ObjectInput;
   
   
   /**
  @@ -15,12 +18,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public final class ClassRetrievalFailedReply extends AltrmiReply
   {
       static final long serialVersionUID = -9005409182642544362L;
   
  +    private String mReason;
  +
       /**
        * Constructor RequestFailedReply
        *
  @@ -31,6 +36,15 @@
       {
       }
   
  +    public ClassRetrievalFailedReply(String reason)
  +    {
  +        mReason = reason;
  +    }
  +
  +    public String getReason() {
  +        return mReason;
  +    }
  +
       /**
        * Method getReplyCode.  This is quicker than instanceof for type checking.
        *
  @@ -42,4 +56,46 @@
       {
           return CLASSRETRIEVALFAILEDREPLY;
       }
  +
  +    /**
  +     * The object implements the writeExternal method to save its contents
  +     * by calling the methods of DataOutput for its primitive values or
  +     * calling the writeObject method of ObjectOutput for objects, strings,
  +     * and arrays.
  +     *
  +     * @serialData Overriding methods should use this tag to describe
  +     *             the data layout of this Externalizable object.
  +     *             List the sequence of element types and, if possible,
  +     *             relate the element to a public/protected field and/or
  +     *             method of this Externalizable class.
  +     *
  +     * @param out the stream to write the object to
  +     * @exception IOException Includes any I/O exceptions that may occur
  +     */
  +    public void writeExternal(ObjectOutput out) throws IOException
  +    {
  +
  +        super.writeExternal(out);
  +        out.writeObject(mReason);
  +    }
  +
  +    /**
  +     * The object implements the readExternal method to restore its
  +     * contents by calling the methods of DataInput for primitive
  +     * types and readObject for objects, strings and arrays.  The
  +     * readExternal method must read the values in the same sequence
  +     * and with the same types as were written by writeExternal.
  +     *
  +     * @param in the stream to read data from in order to restore the object
  +     * @exception IOException if I/O errors occur
  +     * @exception ClassNotFoundException If the class for an object being
  +     *              restored cannot be found.
  +     */
  +    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
  +    {
  +
  +        super.readExternal(in);
  +        mReason = (String) in.readObject();
  +    }
  +
   }
  
  
  
  1.3       +3 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/InvocationHandlerAdapter.java
  
  Index: InvocationHandlerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/InvocationHandlerAdapter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InvocationHandlerAdapter.java	6 Apr 2002 21:29:23 -0000	1.2
  +++ InvocationHandlerAdapter.java	10 Apr 2002 22:33:10 -0000	1.3
  @@ -54,7 +54,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class InvocationHandlerAdapter extends PublicationAdapter
           implements AltrmiInvocationHandler
  @@ -298,7 +298,8 @@
               }
               catch (ClassRetrievalException e)
               {
  -                return new ClassRetrievalFailedReply();
  +                e.printStackTrace();
  +                return new ClassRetrievalFailedReply(e.getMessage());
               }
           }
           else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST)
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/PlainClassRetriever.java
  
  Index: PlainClassRetriever.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/PlainClassRetriever.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlainClassRetriever.java	3 Apr 2002 11:29:56 -0000	1.1
  +++ PlainClassRetriever.java	10 Apr 2002 22:33:10 -0000	1.2
  @@ -23,7 +23,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Vinay Chandrasekharan <a href="mailto:vinay_chandran@users.sourceforge.net">vinay_chandran@users.sourceforge.net</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class PlainClassRetriever extends AbstractClassRetriever
   {
  @@ -57,7 +57,7 @@
   
           InputStream is = null;
   
  -        is = mClassLoader.getResourceAsStream(thingName);
  +        is = mClassLoader.getResourceAsStream(thingName+".class");
   
           if (is == null)
           {
  
  
  
  1.3       +1 -1      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestClient.java
  
  Index: CallBackTestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestClient.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CallBackTestClient.java	8 Apr 2002 20:23:54 -0000	1.2
  +++ CallBackTestClient.java	10 Apr 2002 22:33:11 -0000	1.3
  @@ -43,7 +43,7 @@
   
           AltrmiHostContext arhc;
   
  -        arhc = new SocketCustomStreamHostContext("127.0.0.1", 1235);
  +        arhc = new CallbackEnabledCustomSocketStreamHostContext("127.0.0.1", 1235);
   
           AltrmiFactory af = null;
   
  
  
  
  1.3       +1 -1      jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestServer.java
  
  Index: CallBackTestServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/callback/CallBackTestServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CallBackTestServer.java	8 Apr 2002 20:23:54 -0000	1.2
  +++ CallBackTestServer.java	10 Apr 2002 22:33:11 -0000	1.3
  @@ -39,7 +39,7 @@
   
           System.out.println("CallbackTest Server");
   
  -        AbstractServer as = new CompleteSocketCustomStreamServer(1235);
  +        AbstractServer as = new CallbackEnabledCustomSocketStreamServer(1235);
           
   
           as.setClassRetriever(new JarFileClassRetriever("build/classes2"));
  
  
  

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