hammant 2002/11/25 13:17:08
Modified: altrmi base.xml build.xml
altrmi/src/java/org/apache/excalibur/altrmi/client
ProxyHelper.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl
DefaultProxyHelper.java
altrmi/src/java/org/apache/excalibur/altrmi/common
AltrmiRequestConstants.java
altrmi/src/java/org/apache/excalibur/altrmi/generator
AbstractProxyGenerator.java
BCELProxyGeneratorImpl.java ProxyGeneratorImpl.java
altrmi/src/java/org/apache/excalibur/altrmi/server
PublicationDescription.java
PublicationDescriptionItem.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl
AbstractServer.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters
InvocationHandlerAdapter.java
PublicationAdapter.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers
JavacDynamicGeneratorClassRetriever.java
altrmi/src/test/org/apache/excalibur/altrmi/test/async
SimpleAsyncTestCase.java
Added: altrmi/src/java/org/apache/excalibur/altrmi/common
MethodAsyncRequest.java MethodNameHelper.java
RawRequest.java
Log:
More work on async method invocation
Revision Changes Path
1.7 +0 -9 jakarta-avalon-excalibur/altrmi/base.xml
Index: base.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/base.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- base.xml 14 Nov 2002 23:49:28 -0000 1.6
+++ base.xml 25 Nov 2002 21:17:06 -0000 1.7
@@ -54,15 +54,6 @@
</classpath>
</altrmiproxies>
- <altrmiproxies genname="AsyncTest" srcgendir="${build.home}/genjava"
- classgendir="${build.home}/genclasses" verbose="true"
- interfaces="org.apache.excalibur.altrmi.test.async.AsyncTest">
- <classpath>
- <pathelement location="${build.home}/classes"/>
- <pathelement location="${build.home}/testclasses"/>
- </classpath>
- </altrmiproxies>
-
<altrmiproxies genname="CallBackTestListenerImpl"
srcgendir="${build.home}/genjava"
classgendir="${build.home}/genclasses" verbose="true"
interfaces="org.apache.excalibur.altrmi.test.TestCallBackListener">
1.43 +1 -1 jakarta-avalon-excalibur/altrmi/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/build.xml,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- build.xml 7 Nov 2002 07:57:34 -0000 1.42
+++ build.xml 25 Nov 2002 21:17:06 -0000 1.43
@@ -244,7 +244,7 @@
<formatter type="plain" usefile="false"/> <!-- text reports for humans
-->
<batchtest todir="${build.tests}">
<fileset dir="${build.testclasses}">
- <include name="**/test/**/*TestCase.class"/>
+ <include name="**/test/**/SimpleAsy*TestCase.class"/>
<exclude name="**/Abstract*"/>
<exclude name="**/JSXObjectStreamTestCase.class"/>
</fileset>
1.6 +15 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ProxyHelper.java
Index: ProxyHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/ProxyHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ProxyHelper.java 24 Aug 2002 11:39:05 -0000 1.5
+++ ProxyHelper.java 25 Nov 2002 21:17:07 -0000 1.6
@@ -7,6 +7,8 @@
*/
package org.apache.excalibur.altrmi.client;
+import org.apache.excalibur.altrmi.common.RawRequest;
+
/**
* Interface ProxyHelper
*
@@ -60,6 +62,18 @@
*
*/
void processVoidRequest( String methodSignature, Object[] args ) throws
Throwable;
+
+ /**
+ * Method processVoidRequest
+ *
+ *
+ * @param requests
+ *
+ * @throws Throwable
+ *
+ */
+ void processVoidRequests( RawRequest[] requests ) throws Throwable;
+
/**
* Method processVoidRequestWithRedirect
1.14 +31 -2
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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- DefaultProxyHelper.java 25 Oct 2002 19:05:25 -0000 1.13
+++ DefaultProxyHelper.java 25 Nov 2002 21:17:07 -0000 1.14
@@ -23,6 +23,8 @@
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.RawRequest;
+import org.apache.excalibur.altrmi.common.MethodAsyncRequest;
/**
* Class DefaultProxyHelper
@@ -48,7 +50,7 @@
*
*
* @param altrmiFactory
- * @param invocationHandler
+ * @param clientInvocationHandler
* @param pubishedServiceName
* @param objectName
* @param referenceID
@@ -245,6 +247,33 @@
MethodReply or = (MethodReply)reply;
return or.getReplyObject();
+ }
+ else if( reply.getReplyCode() == AltrmiReplyConstants.EXCEPTIONREPLY )
+ {
+ ExceptionReply er = (ExceptionReply)reply;
+
+ throw er.getReplyException();
+ }
+ else
+ {
+ throw new AltrmiInvocationException( "Internal Error : Unknown reply
type :"
+ + reply.getClass().getName() );
+ }
+ }
+
+ public void processVoidRequests(RawRequest[] requests) throws Throwable
+ {
+ MethodAsyncRequest request = new MethodAsyncRequest( mPublishedServiceName,
mObjectName,
+ requests, mReferenceID, mSession
);
+
+ //debug(args);
+ AltrmiReply reply = mClientInvocationHandler.handleInvocation( request );
+
+ if( reply.getReplyCode() == AltrmiReplyConstants.METHODREPLY )
+ {
+ MethodReply or = (MethodReply)reply;
+
+ return;
}
else if( reply.getReplyCode() == AltrmiReplyConstants.EXCEPTIONREPLY )
{
1.3 +7 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/AltrmiRequestConstants.java
Index: AltrmiRequestConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/AltrmiRequestConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AltrmiRequestConstants.java 1 Nov 2002 16:35:42 -0000 1.2
+++ AltrmiRequestConstants.java 25 Nov 2002 21:17:07 -0000 1.3
@@ -51,4 +51,10 @@
* A request for listing the methods within the publishedName
*/
int LISTMETHODSREQUEST=309;
+
+ /**
+ * A method request
+ */
+ int METHODASYNCREQUEST = 310;
+
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodAsyncRequest.java
Index: MethodAsyncRequest.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.altrmi.common;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
/**
* Class MethodAsyncRequest
*
*
* @author Paul Hammant
* @version $Revision: 1.1 $
*/
public class MethodAsyncRequest extends PublishedNameRequest implements Sessionable
{
static final long serialVersionUID = -909163040319879134L;
private RawRequest[] m_rawRequests;
private Long m_referenceID;
private Long m_session;
/**
* Constructor MethodRequest
*
*
* @param publishedServiceName the published service name
* @param objectName the object Name
* @param rawRequests The raw requests
* @param referenceID the reference ID
* @param session the session ID
*
*/
public MethodAsyncRequest( String publishedServiceName, String objectName,
RawRequest[] rawRequests, Long referenceID, Long session )
{
super( publishedServiceName, objectName );
m_rawRequests = rawRequests;
m_referenceID = referenceID;
m_session = session;
}
/**
* Constructor MethodRequest for Externalization
*
*
*/
public MethodAsyncRequest()
{
}
public RawRequest[] getRawRequests()
{
return m_rawRequests;
}
/**
* Get the reference ID.
*
*
* @return the reference ID
*
*/
public Long getReferenceID()
{
return m_referenceID;
}
/**
* Gets number that represents type for this class.
* This is quicker than instanceof for type checking.
*
* @return the representative code
* @see AltrmiRequestConstants
*
*/
public int getRequestCode()
{
return AltrmiRequestConstants.METHODASYNCREQUEST;
}
/**
* Get the session ID.
*
*
* @return the session ID
*
*/
public Long getSession()
{
return m_session;
}
/**
* 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( m_rawRequests );
out.writeObject( m_referenceID );
out.writeObject( m_session );
}
/**
* 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 );
m_rawRequests = (RawRequest[])in.readObject();
m_referenceID = (Long)in.readObject();
m_session = (Long)in.readObject();
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/MethodNameHelper.java
Index: MethodNameHelper.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.altrmi.common;
import java.lang.reflect.Method;
/**
* Class MethodNameHelper
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public final class MethodNameHelper
{
/**
* Generate a string representation of a method signature
*
*
* @param method The method that needs a signature
*
* @return String representing method sig
*/
public static String getMethodSignature(Method method)
{
StringBuffer methodSignature = new StringBuffer();
methodSignature.append(method.getName()).append("(");
Class[] params = method.getParameterTypes();
for (int i = 0; i < params.length; i++)
{
methodSignature.append(params[i].getName());
if (i + 1 < params.length)
{
methodSignature.append(", ");
}
}
methodSignature.append(")");
return methodSignature.toString().intern();
}
/**
* Encode a classname - i.e. escapes dots for dollars in package/class name
*
*
* @param clazz class that has name that needs encoding.
*
* @return String encoded class name
*/
public static String encodeClassName(Class clazz)
{
return encodeClassName(clazz.getName());
}
/**
* Encode a classname - i.e. escapes dots for dollars in package/class name
*
*
* @param className class name that needs encoding.
*
* @return String encoded class name
*/
public static String encodeClassName(String className)
{
return className.replace('.', '$');
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/RawRequest.java
Index: RawRequest.java
===================================================================
package org.apache.excalibur.altrmi.common;
public class RawRequest
{
private String m_methodSignature;
private Object[] m_args;
public RawRequest(String methodSignature, Object[] args)
{
m_methodSignature = methodSignature;
m_args = args;
}
}
1.4 +21 -3
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/AbstractProxyGenerator.java
Index: AbstractProxyGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/AbstractProxyGenerator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractProxyGenerator.java 14 Nov 2002 23:49:28 -0000 1.3
+++ AbstractProxyGenerator.java 25 Nov 2002 21:17:07 -0000 1.4
@@ -7,7 +7,6 @@
*/
package org.apache.excalibur.altrmi.generator;
-import org.apache.excalibur.altrmi.common.AbstractMethodHandler;
import org.apache.excalibur.altrmi.common.ProxyGenerator;
import org.apache.excalibur.altrmi.common.ProxyGenerationException;
import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
@@ -21,7 +20,7 @@
*
*/
-public abstract class AbstractProxyGenerator extends AbstractMethodHandler
+public abstract class AbstractProxyGenerator
implements ProxyGenerator
{
@@ -267,4 +266,23 @@
// default impl
}
+ /**
+ *
+ * @param publicationDescriptionItemses
+ * @return
+ */
+ protected boolean needsAsyncBehavior(PublicationDescriptionItem[]
publicationDescriptionItemses)
+ {
+ for (int i = 0; i < publicationDescriptionItemses.length; i++)
+ {
+ PublicationDescriptionItem publicationDescriptionItem =
publicationDescriptionItemses[i];
+ if (publicationDescriptionItem.getAsyncMethods().length != 0
+ | publicationDescriptionItem.getCommitMethod() != null
+ | publicationDescriptionItem.getRollbackMethod() != null)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
}
1.8 +7 -6
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/BCELProxyGeneratorImpl.java
Index: BCELProxyGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/BCELProxyGeneratorImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BCELProxyGeneratorImpl.java 14 Nov 2002 23:49:28 -0000 1.7
+++ BCELProxyGeneratorImpl.java 25 Nov 2002 21:17:07 -0000 1.8
@@ -34,6 +34,7 @@
import org.apache.bcel.generic.PUSH;
import org.apache.bcel.generic.Type;
import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
+import org.apache.excalibur.altrmi.common.MethodNameHelper;
/**
* Class BCElProxyGeneratorImpl
@@ -77,7 +78,7 @@
{
for (int i = 0; i < getAdditionalFacades().length; i++)
{
- String encodedClassName =
encodeClassName(getAdditionalFacades()[i].getFacadeClass());
+ String encodedClassName =
MethodNameHelper.encodeClassName(getAdditionalFacades()[i].getFacadeClass());
generateAltrmiProxyClass(
STUB_PREFIX + getGenName() + "_" + encodedClassName,
new PublicationDescriptionItem[] { getAdditionalFacades()[i] });
@@ -560,7 +561,7 @@
if (isAdditionalFacade(mth.getReturnType()))
{
- String encodedReturnClassName="class$" + encodeClassName(returnClass);
+ String encodedReturnClassName="class$" +
MethodNameHelper.encodeClassName(returnClass);
addField(encodedReturnClassName);
il.append(
m_factory.createFieldAccess(
@@ -599,10 +600,10 @@
new ObjectType("java.lang.Class"),
Constants.PUTSTATIC));
InstructionHandle ihPushSignature =
- il.append(new PUSH(m_constantsPool, getMethodSignature(mth)));
+ il.append(new PUSH(m_constantsPool,
MethodNameHelper.getMethodSignature(mth)));
gotoReturnClass.setTarget(ihPushSignature);
il.append(m_factory.createLoad(Type.OBJECT, variableIndex-1));
- il.append(new PUSH(m_constantsPool, encodeClassName( getClassType(
returnClass ) )));
+ il.append(new PUSH(m_constantsPool, MethodNameHelper.encodeClassName(
getClassType( returnClass ) )));
il.append(
m_factory.createInvoke(
"org.apache.excalibur.altrmi.client.ProxyHelper",
@@ -618,7 +619,7 @@
else
{
//method signature = METHODNAME(arguments....)
- il.append(new PUSH(m_constantsPool, getMethodSignature(mth)));
+ il.append(new PUSH(m_constantsPool,
MethodNameHelper.getMethodSignature(mth)));
variableIndex -= 2;
il.append(m_factory.createLoad(Type.OBJECT, ++variableIndex));
il.append(m_factory.createLoad(Type.OBJECT, ++variableIndex));
1.14 +78 -19
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java
Index: ProxyGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ProxyGeneratorImpl.java 14 Nov 2002 23:49:28 -0000 1.13
+++ ProxyGeneratorImpl.java 25 Nov 2002 21:17:07 -0000 1.14
@@ -15,6 +15,7 @@
import java.lang.reflect.Method;
import java.util.Vector;
import org.apache.excalibur.altrmi.common.ProxyGenerationException;
+import org.apache.excalibur.altrmi.common.MethodNameHelper;
import org.apache.excalibur.altrmi.javacompiler.JavaCompiler;
import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
@@ -54,8 +55,8 @@
{
PublicationDescriptionItem facade = getAdditionalFacades()[ i ];
- makeSource( classLoader, encodeClassName( facade.getFacadeClass()
), new PublicationDescriptionItem[]{facade} );
- makeSource2( classLoader, encodeClassName( facade.getFacadeClass()
), new PublicationDescriptionItem[]{facade} );
+ makeSource( classLoader, MethodNameHelper.encodeClassName(
facade.getFacadeClass() ), new PublicationDescriptionItem[]{facade} );
+ makeSource2( classLoader, MethodNameHelper.encodeClassName(
facade.getFacadeClass() ), new PublicationDescriptionItem[]{facade} );
}
}
}
@@ -88,7 +89,7 @@
{
for( int i = 0; i < getAdditionalFacades().length; i++ )
{
- String classname = encodeClassName( getAdditionalFacades()[ i
].getFacadeClass() );
+ String classname = MethodNameHelper.encodeClassName(
getAdditionalFacades()[ i ].getFacadeClass() );
jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated"
+ getGenName() + "_" + classname + ".java" );
@@ -143,8 +144,8 @@
}
catch( FileNotFoundException e )
{
- throw new ProxyGenerationException( "Cannot make source output file '"
+ filename
- + "'" );
+ throw new ProxyGenerationException( "Cannot make source output file '"
+ + filename + "'" );
}
m_classSource.print( "public class AltrmiGenerated" + getGenName() + "_" +
name );
@@ -152,6 +153,13 @@
m_classSource.println(
" private transient org.apache.excalibur.altrmi.client.ProxyHelper
mProxyHelper;" );
+ if (needsAsyncBehavior(interfacesToExpose))
+ {
+ m_classSource.println(
+ " private transient java.util.Vector m_asyncInvocations = new
java.util.Vector();" );
+
+ }
+
// Generate Constructor
m_classSource.println(
" public AltrmiGenerated" + getGenName() + "_" + name
@@ -179,7 +187,8 @@
// TODO DefaultProxyHelper altrmiGetProxyHelper();
for( int x = 0; x < interfacesToExpose.length; x++ )
{
- Class clazz = interfacesToExpose[ x ].getFacadeClass();
+ PublicationDescriptionItem interfaceToExpose = interfacesToExpose[ x ];
+ Class clazz = interfaceToExpose.getFacadeClass();
if( isVerbose() )
{
@@ -191,7 +200,7 @@
for( int y = 0; y < methods.length; y++ )
{
Method method = methods[ y ];
- String methodSignature = getMethodSignature( method );
+ String methodSignature = MethodNameHelper.getMethodSignature(
method );
if( isVerbose() )
{
@@ -200,7 +209,15 @@
if( !methodsDone.contains( methodSignature ) )
{
- makeSourceInterfacesMethodsNotDone(methodsDone,
methodSignature, method);
+ makeSourceInterfacesMethodsNotDone(
+ methodsDone,
+ methodSignature,
+ method,
+ interfaceToExpose.isAsync(method),
+ interfaceToExpose.isCommit(method),
+ interfaceToExpose.isRollback(method)
+
+ );
}
}
@@ -208,7 +225,9 @@
}
private void makeSourceInterfacesMethodsNotDone(Vector methodsDone,
- String methodSignature, Method method) throws ProxyGenerationException
+ String methodSignature, Method method,
+ boolean async, boolean commit, boolean rollback)
+ throws ProxyGenerationException
{
methodsDone.add( methodSignature );
@@ -252,15 +271,35 @@
}
m_classSource.println( "{" );
- m_classSource.println( " Object[] args = new Object[" + argTypes.length
- + "];" );
- m_classSource.println( " Class[] argClasses = new Class[" +
argTypes.length
- + "];" );
-
- for( int i = 0; i < argTypes.length; i++ )
+ if (async)
{
- generateAssignLine( argTypes[ i ], i );
+ generateAsyncMethodBody(argTypes, rClass, methodSignature, method);
+ }
+ else if (commit)
+ {
+ generateAsyncMethodBody(argTypes, rClass, methodSignature, method);
+ generateAsyncCommitMethodBody(argTypes, rClass, methodSignature,
method);
+ }
+ else if (rollback)
+ {
+ // generateAsyncRollbackMethodBody(argTypes, rClass, methodSignature,
method);
}
+ else
+ {
+ generateNonAsyncMethodBody(argTypes, rClass, methodSignature, method);
+ }
+ m_classSource.println( "}" );
+ }
+
+ private void generateAsyncCommitMethodBody(Class[] argTypes, Class rClass,
String methodSignature, Method method)
+ {
+
+ }
+
+ private void generateNonAsyncMethodBody(Class[] argTypes, Class rClass, String
methodSignature, Method method)
+ {
+ Class[] throwsTypes;
+ generateMethodArgs(argTypes);
m_classSource.println( " try {" );
@@ -295,9 +334,29 @@
+ "AltrmiInvocationException(\"Should never get here: \"
+t.getMessage());");
m_classSource.println( " }" );
m_classSource.println( " }" );
- m_classSource.println( " }" );
}
+ private void generateMethodArgs(Class[] argTypes)
+ {
+ m_classSource.println( " Object[] args = new Object[" + argTypes.length
+ + "];" );
+ m_classSource.println( " Class[] argClasses = new Class[" +
argTypes.length
+ + "];" );
+
+ for( int i = 0; i < argTypes.length; i++ )
+ {
+ generateAssignLine( argTypes[ i ], i );
+ }
+ }
+
+ private void generateAsyncMethodBody(Class[] argTypes, Class rClass, String
methodSignature, Method method)
+ {
+ generateMethodArgs(argTypes);
+ m_classSource.println( " m_asyncInvocations.add(new
org.apache.excalibur.altrmi.common.RawRequest(\""
+ + methodSignature + "\", args));" );
+ }
+
+
private void makeSourceInterfacesMethodsNotDoneNotVoid(Method method,
Class rClass, String methodSignature)
{
@@ -315,7 +374,7 @@
" Object retVal = mProxyHelper.processObjectRequestGettingFacade("
+ retClassType.getName() + ".class , \""
+ methodSignature.toString() + "\",args,\""
- + encodeClassName( getClassType( rClass ) ) + "\");" );
+ + MethodNameHelper.encodeClassName( getClassType( rClass ) ) +
"\");" );
m_classSource.println( " return (" + getClassType( rClass )
+ ") retVal;" );
}
1.7 +5 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescription.java
Index: PublicationDescription.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescription.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PublicationDescription.java 14 Nov 2002 23:49:28 -0000 1.6
+++ PublicationDescription.java 25 Nov 2002 21:17:08 -0000 1.7
@@ -182,6 +182,10 @@
makeClasses( additionalFacades, classLoader ) );
}
+ public PublicationDescription()
+ {
+ }
+
private static Class[] makeClasses( String[] classNames, ClassLoader
classLoader )
throws PublicationException
{
1.2 +63 -3
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescriptionItem.java
Index: PublicationDescriptionItem.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/PublicationDescriptionItem.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PublicationDescriptionItem.java 14 Nov 2002 23:49:28 -0000 1.1
+++ PublicationDescriptionItem.java 25 Nov 2002 21:17:08 -0000 1.2
@@ -7,6 +7,10 @@
*/
package org.apache.excalibur.altrmi.server;
+import org.apache.excalibur.altrmi.common.MethodNameHelper;
+
+import java.lang.reflect.Method;
+
/**
* Class PublicationDescriptionItem
*
@@ -19,11 +23,15 @@
private final Class m_facadeClass;
private final String[] m_asyncMethods;
+ private final String m_commitMethod;
+ private final String m_rollbackMethod;
public PublicationDescriptionItem(Class facadeClass)
{
- this.m_facadeClass = facadeClass;
- this.m_asyncMethods = new String[0];
+ m_facadeClass = facadeClass;
+ m_asyncMethods = new String[0];
+ m_commitMethod = null;
+ m_rollbackMethod = null;
}
public PublicationDescriptionItem(Class facadeClass, String[] asyncMethods)
@@ -34,6 +42,21 @@
throw new RuntimeException("Facade class nust not be null");
}
this.m_asyncMethods = asyncMethods;
+ m_commitMethod = null;
+ m_rollbackMethod = null;
+ }
+
+ public PublicationDescriptionItem(Class facadeClass, String[] asyncMethods,
+ String commitMethod, String rollbackMethod)
+ {
+ m_facadeClass = facadeClass;
+ if (facadeClass == null)
+ {
+ throw new RuntimeException("Facade class nust not be null");
+ }
+ m_asyncMethods = asyncMethods;
+ m_commitMethod = commitMethod;
+ m_rollbackMethod = rollbackMethod;
}
public Class getFacadeClass()
@@ -45,4 +68,41 @@
{
return m_asyncMethods;
}
+
+ public String getCommitMethod()
+ {
+ return m_commitMethod;
+ }
+
+ public String getRollbackMethod()
+ {
+ return m_rollbackMethod;
+ }
+
+ public boolean isAsync(Method method)
+ {
+ String mthSig = MethodNameHelper.getMethodSignature(method);
+ for (int i = 0; i < m_asyncMethods.length; i++)
+ {
+ String asyncMethod = m_asyncMethods[i];
+ if (asyncMethod.equals(mthSig))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isCommit(Method method)
+ {
+ String mthSig = MethodNameHelper.getMethodSignature(method);
+ return mthSig.equals(m_commitMethod);
+ }
+
+ public boolean isRollback(Method method)
+ {
+ String mthSig = MethodNameHelper.getMethodSignature(method);
+ return mthSig.equals(m_rollbackMethod);
+ }
+
}
1.9 +2 -3
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AbstractServer.java
Index: AbstractServer.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/AbstractServer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- AbstractServer.java 13 Oct 2002 11:54:26 -0000 1.8
+++ AbstractServer.java 25 Nov 2002 21:17:08 -0000 1.9
@@ -11,7 +11,6 @@
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.excalibur.altrmi.common.AbstractMethodHandler;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
import org.apache.excalibur.altrmi.common.MethodRequest;
@@ -32,7 +31,7 @@
* @author Vinay Chandrasekharan <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision$
*/
-public abstract class AbstractServer extends AbstractMethodHandler
+public abstract class AbstractServer
implements AltrmiServer, LogEnabled
{
1.13 +4 -3
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- InvocationHandlerAdapter.java 24 Nov 2002 07:16:34 -0000 1.12
+++ InvocationHandlerAdapter.java 25 Nov 2002 21:17:08 -0000 1.13
@@ -42,6 +42,7 @@
import org.apache.excalibur.altrmi.common.RequestFailedReply;
import org.apache.excalibur.altrmi.common.SameVMReply;
import org.apache.excalibur.altrmi.common.SuspendedReply;
+import org.apache.excalibur.altrmi.common.MethodNameHelper;
import org.apache.excalibur.altrmi.server.AltrmiAuthenticator;
import org.apache.excalibur.altrmi.server.ClassRetrievalException;
import org.apache.excalibur.altrmi.server.ClassRetriever;
@@ -242,7 +243,7 @@
MethodInvocationHandler mainMethodInvocationHandler =
getMethodInvocationHandler(methodFacadeRequest.getPublishedServiceName() + "_Main" );
- objectNames[ i ] = encodeClassName(
+ objectNames[ i ] = MethodNameHelper.encodeClassName(
mainMethodInvocationHandler.getMostDerivedType( beanImpls[ i ]
).getName() );
MethodInvocationHandler methodInvocationHandler2 =
@@ -293,7 +294,7 @@
MethodInvocationHandler mainMethodInvocationHandler =
getMethodInvocationHandler(
methodFacadeRequest.getPublishedServiceName() + "_Main" );
- String objectName = encodeClassName(
+ String objectName = MethodNameHelper.encodeClassName(
mainMethodInvocationHandler.getMostDerivedType( beanImpl
).getName() );
MethodInvocationHandler methodInvocationHandler =
getMethodInvocationHandler (
1.7 +6 -6
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java
Index: PublicationAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/PublicationAdapter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- PublicationAdapter.java 14 Nov 2002 23:49:28 -0000 1.6
+++ PublicationAdapter.java 25 Nov 2002 21:17:08 -0000 1.7
@@ -11,8 +11,8 @@
import java.util.HashMap;
import java.util.Iterator;
-import org.apache.excalibur.altrmi.common.AbstractMethodHandler;
import org.apache.excalibur.altrmi.common.MethodRequest;
+import org.apache.excalibur.altrmi.common.MethodNameHelper;
import org.apache.excalibur.altrmi.server.*;
import org.apache.excalibur.altrmi.server.impl.DefaultMethodInvocationHandler;
@@ -23,7 +23,7 @@
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision$
*/
-public class PublicationAdapter extends AbstractMethodHandler implements
AltrmiPublisher
+public class PublicationAdapter implements AltrmiPublisher
{
/**
@@ -111,7 +111,7 @@
for( int y = 0; y < methods.length; y++ )
{
Method method = methods[ y ];
- String methodSignature = getMethodSignature( method );
+ String methodSignature = MethodNameHelper.getMethodSignature(
method );
if( !mainMethodMap.containsKey( methodSignature.toString() ) )
{
@@ -127,7 +127,7 @@
for( int x = 0; x < additionalFacades.length; x++ )
{
Method methods[] = additionalFacades[ x ].getFacadeClass().getMethods();
- String encodedClassName = encodeClassName( additionalFacades[ x
].getFacadeClass().getName() );
+ String encodedClassName = MethodNameHelper.encodeClassName(
additionalFacades[ x ].getFacadeClass().getName() );
HashMap methodMap = new HashMap();
MethodInvocationHandler methodInvocationHandler =
new DefaultMethodInvocationHandler( this, asName + "_" +
encodedClassName,
@@ -136,7 +136,7 @@
for( int y = 0; y < methods.length; y++ )
{
Method method = methods[ y ];
- String methodSignature = getMethodSignature( method );
+ String methodSignature = MethodNameHelper.getMethodSignature(
method );
if( !methodMap.containsKey( methodSignature.toString() ) )
{
1.5 +4 -5
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JavacDynamicGeneratorClassRetriever.java
Index: JavacDynamicGeneratorClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JavacDynamicGeneratorClassRetriever.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JavacDynamicGeneratorClassRetriever.java 24 Aug 2002 11:39:06 -0000 1.4
+++ JavacDynamicGeneratorClassRetriever.java 25 Nov 2002 21:17:08 -0000 1.5
@@ -21,20 +21,19 @@
*
* @param classLoader the classloader in which the proxy generater will be
found.
*/
-
public JavacDynamicGeneratorClassRetriever(ClassLoader classLoader)
{
- super(classLoader,
"org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl");
+ super(classLoader,
+ "org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl");
}
/**
* Contruct a Dynamic Class Generator using the classes own classloader.
*
*/
-
public JavacDynamicGeneratorClassRetriever()
{
super(JavacDynamicGeneratorClassRetriever.class.getClassLoader(),
- "org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl");
+ "org.apache.excalibur.altrmi.generator.ProxyGeneratorImpl");
}
}
1.2 +34 -18
jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/async/SimpleAsyncTestCase.java
Index: SimpleAsyncTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/async/SimpleAsyncTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SimpleAsyncTestCase.java 14 Nov 2002 23:49:29 -0000 1.1
+++ SimpleAsyncTestCase.java 25 Nov 2002 21:17:08 -0000 1.2
@@ -8,12 +8,16 @@
package org.apache.excalibur.altrmi.test.async;
import
org.apache.excalibur.altrmi.server.impl.socket.CompleteSocketCustomStreamServer;
+import
org.apache.excalibur.altrmi.server.impl.classretrievers.JavacDynamicGeneratorClassRetriever;
import org.apache.excalibur.altrmi.server.PublicationDescription;
-import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
+import org.apache.excalibur.altrmi.server.PublicationDescriptionItem;
+import org.apache.excalibur.altrmi.client.impl.ServerClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.socket.SocketCustomStreamHostContext;
import org.apache.excalibur.altrmi.client.AltrmiFactory;
import junit.framework.TestCase;
+import java.io.File;
+
public class SimpleAsyncTestCase extends TestCase
{
@@ -32,15 +36,32 @@
super.setUp();
// server side setup.
- server = new CompleteSocketCustomStreamServer(11001);
+ server = new CompleteSocketCustomStreamServer(11003);
+ JavacDynamicGeneratorClassRetriever cr = new
JavacDynamicGeneratorClassRetriever(
+ this.getClass().getClassLoader());
+ cr.setClassGenDir(".");
+ cr.setAltrmiClasspath("..\\build\\classes;C:\\j2sdk1.4.1\\lib\\tools.jar");
+ cr.setSrcGenDir(".");
+ server.setClassRetriever(cr);
asyncTestImpl = new AsyncTestImpl();
- PublicationDescription pd = new PublicationDescription(AsyncTest.class);
+ PublicationDescription pd = new PublicationDescription();
+ pd.addInterfaceToExpose(
+ new PublicationDescriptionItem(AsyncTest.class,
+ new String[]{"setOne(java.lang.String)",
+ "setTwo(java.lang.String)",
+ "setThree(java.lang.String)"
+ }//,
+ // "fire()", null
+ )
+ );
+ cr.generate("AsyncTest",pd, this.getClass().getClassLoader());
server.publish(asyncTestImpl, "AsyncTest", pd);
server.start();
// Client side setup
- altrmiFactory = new ClientClassAltrmiFactory(false);
- altrmiFactory.setHostContext(new SocketCustomStreamHostContext("127.0.0.1",
11001), false);
+ altrmiFactory = new ServerClassAltrmiFactory(false);
+ altrmiFactory.setHostContext(
+ new SocketCustomStreamHostContext("127.0.0.1", 11003), false);
testClient = (AsyncTest) altrmiFactory.lookup("AsyncTest");
// just a kludge for unit testing given we are intrinsically dealing with
@@ -48,11 +69,6 @@
Thread.yield();
}
- public void testTrue()
- {
-
- }
-
public void testSimpleAsync() throws Exception
{
@@ -60,17 +76,17 @@
testClient.setTwo("two");
testClient.setThree("three");
- assertNull("One should be null", asyncTestImpl.one);
- assertNull("Two should be null", asyncTestImpl.two);
- assertNull("Tree should be null", asyncTestImpl.three);
- assertFalse("Fire should be false", asyncTestImpl.fired);
+ assertNull("Field 'One' should be null", asyncTestImpl.one);
+ assertNull("Field 'Two' should be null", asyncTestImpl.two);
+ assertNull("Field 'Tree' should be null", asyncTestImpl.three);
+ assertFalse("Field 'Fire' should be false", asyncTestImpl.fired);
testClient.fire();
- assertNotNull("One should not be null", asyncTestImpl.one);
- assertNotNull("Two should not be null", asyncTestImpl.two);
- assertNotNull("Tree should not be null", asyncTestImpl.three);
- assertTrue("Fire should not be false", asyncTestImpl.fired);
+ assertNotNull("Field 'One' should not be null", asyncTestImpl.one);
+ assertNotNull("Field 'Two' should not be null", asyncTestImpl.two);
+ assertNotNull("Field 'Tree' should not be null", asyncTestImpl.three);
+ assertTrue("Field 'Fire' should not be false", asyncTestImpl.fired);
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>