hammant 2002/11/25 22:09:55 Modified: altrmi 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 RawRequest.java altrmi/src/java/org/apache/excalibur/altrmi/generator ProxyGeneratorImpl.java altrmi/src/java/org/apache/excalibur/altrmi/server PublicationDescriptionItem.java altrmi/src/java/org/apache/excalibur/altrmi/server/impl StreamServerConnection.java altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters InvocationHandlerAdapter.java MarshalledInvocationHandlerAdapter.java altrmi/src/test/org/apache/excalibur/altrmi/test/async SimpleAsyncTestCase.java Log: Asynchronous method invocation works to a point. Revision Changes Path 1.44 +37 -36 jakarta-avalon-excalibur/altrmi/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/build.xml,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- build.xml 25 Nov 2002 21:17:06 -0000 1.43 +++ build.xml 26 Nov 2002 06:09:54 -0000 1.44 @@ -3,13 +3,13 @@ <project name="Excalibur AltRMI" default="main" basedir="."> <property file="ant.properties"/> - <property file="${basedir}/../ant.properties"/> - <property file="${basedir}/ant.properties"/> + <property file="${basedir}/../ant.properties"/> + <property file="${basedir}/ant.properties"/> <property file="${basedir}/../default.properties"/> - <property file="${basedir}/default.properties"/> + <property file="${basedir}/default.properties"/> <property file="${user.home}/.ant.properties"/> <property file="default.properties"/> - + <!-- Classpath for product --> <path id="project.class.path"> <pathelement location="${build.classes}"/> @@ -33,7 +33,7 @@ <pathelement location="${junit.jar}"/> <path refid="project.class.path"/> </path> - + <path id="test.classpath2"> <pathelement location="${build.testclasses}"/> <pathelement location="${junit.jar}"/> @@ -41,19 +41,19 @@ <pathelement location="lib/JSX1.0.3.1.jar"/> <path refid="project.class.path"/> </path> - + <path id="test.classpath3"> <pathelement location="${build.testclasses}"/> <pathelement location="${junit.jar}"/> <path refid="project.class.path"/> </path> - + <property name="cp" refid="test.class.path"/> <target name="main" depends="compile, compile-test" description="Build the project"/> <target name="rebuild" depends="clean,main" description="Rebuild the project"/> - + <target name="checkBCEL"> <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkRequiredClass"> <property name="proj.jar.name" value="jakarta-bcel.jar"/> @@ -94,12 +94,12 @@ <classpath refid="project.class.path" /> <include name="**/*.java"/> </javac> - + <rmic base="${build.classes}" classname="org.apache.excalibur.altrmi.server.impl.rmi.RmiInovcationAdapter" stubVersion="1.2"> - <classpath refid="project.class.path" /> - </rmic> + <classpath refid="project.class.path" /> + </rmic> <!-- copy resources to same location as .class files --> <copy todir="${build.classes}"> @@ -115,8 +115,8 @@ <target name="compile-test" depends="compile, dependencies-test" description="Compiles the source code"> <mkdir dir="${build.testsrc}"/> - <filter token="SPEEDTEST-ITERATIONS" value="${speedtest.iterations}"/> - + <filter token="SPEEDTEST-ITERATIONS" value="${speedtest.iterations}"/> + <echo>Speed Test Iterations=${speedtest.iterations}</echo> <!-- Copy over all of the tests applying test filters --> @@ -170,37 +170,37 @@ compress="${build.compress}" manifest="src/conf/MANIFEST-client-impl.MF"> <include name="org/apache/excalibur/altrmi/client/impl/**"/> - </jar> + </jar> <jar jarfile="${build.lib}/${server-interfaces.jar.name}" basedir="${build.classes}" compress="${build.compress}" manifest="src/conf/MANIFEST-server-interfaces.MF"> <include name="org/apache/excalibur/altrmi/server/*"/> - </jar> + </jar> <jar jarfile="${build.lib}/${server-impl.jar.name}" basedir="${build.classes}" compress="${build.compress}" manifest="src/conf/MANIFEST-server-impl.MF"> <include name="org/apache/excalibur/altrmi/server/impl/**"/> - </jar> + </jar> <jar jarfile="${build.lib}/${generator.jar.name}" basedir="${build.classes}" manifest="src/conf/MANIFEST-generator.MF"> <include name="org/apache/excalibur/altrmi/generator/**"/> - <include name="org/apache/excalibur/altrmi/javacompiler/**"/> - </jar> + <include name="org/apache/excalibur/altrmi/javacompiler/**"/> + </jar> <jar jarfile="${build.lib}/${registry.jar.name}" basedir="${build.classes}" manifest="src/conf/MANIFEST-registry.MF"> <include name="org/apache/excalibur/altrmi/registry/**"/> - </jar> + </jar> + - </target> <!-- Creates all the Javadocs --> @@ -228,12 +228,12 @@ <echo message="Performing Unit Tests" /> - <ant antfile="base.xml" target="generate"/> + <ant antfile="base.xml" target="generate"/> <mkdir dir="${build.tests}"/> <!-- Plain tests --> - + <junit fork="true" haltonfailure="${junit.failonerror}" printsummary="yes" @@ -244,7 +244,8 @@ <formatter type="plain" usefile="false"/> <!-- text reports for humans --> <batchtest todir="${build.tests}"> <fileset dir="${build.testclasses}"> - <include name="**/test/**/SimpleAsy*TestCase.class"/> + <!-- <include name="**/test/**/SimpleAsy*TestCase.class"/> --> + <include name="**/test/**/*TestCase.class"/> <exclude name="**/Abstract*"/> <exclude name="**/JSXObjectStreamTestCase.class"/> </fileset> @@ -252,7 +253,7 @@ </junit> <!-- Dynamic Server Side classes --> - + <junit fork="true" haltonfailure="${junit.failonerror}" printsummary="yes" @@ -329,7 +330,7 @@ <include name="org/apache/excalibur/altrmi/generator/*.java"/> <include name="org/apache/excalibur/altrmi/server/*.java"/> <include name="org/apache/excalibur/altrmi/registry/**.java"/> - <include name="org/apache/excalibur/altrmi/server/impl/*.java"/> + <include name="org/apache/excalibur/altrmi/server/impl/*.java"/> <include name="org/apache/excalibur/altrmi/server/impl/adapters/*.java"/> <include name="org/apache/excalibur/altrmi/server/impl/callback/*.java"/> <include name="org/apache/excalibur/altrmi/server/impl/classretrievers/*.java"/> @@ -405,8 +406,8 @@ <fileset dir="${build.lib}"> <include name="*.jar"/> </fileset> - </copy> - </target> + </copy> + </target> <!-- Creates a minimal distribution --> <target name="dist.lite" @@ -444,8 +445,8 @@ <filter token="LOGKIT_BASE" value="${logkit.base}"/> <filter token="TESTLET_BASE" value="${testlet.base}"/> </target> - - + + <!-- Prepares the documentation directory --> <target name="docs" depends="setup-filters" description="Generates the Docs"> <ant antfile="${basedir}/../cocoonbuild.xml"/> @@ -454,19 +455,19 @@ <fileset dir="${build.docs}"> <include name="**"/> </fileset> - </copy> + </copy> </target> - - <target name="site" depends="javadocs, docs" description=" Places Docs ready for hosting on website"> - - <mkdir dir="../site/dist/docs/${dir-name}"/> + + <target name="site" depends="javadocs, docs" description=" Places Docs ready for hosting on website"> + + <mkdir dir="../site/dist/docs/${dir-name}"/> <copy todir="../site/dist/docs/${dir-name}"> <fileset dir="${docs.dir}"> <include name="**"/> </fileset> - </copy> - + </copy> + </target> <!-- Cleans up build and distribution directories --> 1.7 +3 -3 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.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ProxyHelper.java 25 Nov 2002 21:17:07 -0000 1.6 +++ ProxyHelper.java 26 Nov 2002 06:09:55 -0000 1.7 @@ -7,7 +7,7 @@ */ package org.apache.excalibur.altrmi.client; -import org.apache.excalibur.altrmi.common.RawRequest; +import java.util.Vector; /** * Interface ProxyHelper @@ -72,7 +72,7 @@ * @throws Throwable * */ - void processVoidRequests( RawRequest[] requests ) throws Throwable; + void processVoidRequests( Vector requests ) throws Throwable; /** 1.15 +61 -56 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DefaultProxyHelper.java 25 Nov 2002 21:17:07 -0000 1.14 +++ DefaultProxyHelper.java 26 Nov 2002 06:09:55 -0000 1.15 @@ -7,8 +7,6 @@ */ package org.apache.excalibur.altrmi.client.impl; -import java.lang.reflect.Array; - import org.apache.excalibur.altrmi.client.AltrmiClientInvocationHandler; import org.apache.excalibur.altrmi.client.AltrmiProxy; import org.apache.excalibur.altrmi.client.ProxyHelper; @@ -18,13 +16,17 @@ import org.apache.excalibur.altrmi.common.ExceptionReply; import org.apache.excalibur.altrmi.common.GarbageCollectionReply; import org.apache.excalibur.altrmi.common.GarbageCollectionRequest; +import org.apache.excalibur.altrmi.common.MethodAsyncRequest; import org.apache.excalibur.altrmi.common.MethodFacadeArrayReply; import org.apache.excalibur.altrmi.common.MethodFacadeReply; 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; + +import javax.swing.*; +import java.lang.reflect.Array; +import java.util.Vector; /** * Class DefaultProxyHelper @@ -37,12 +39,12 @@ public final class DefaultProxyHelper implements ProxyHelper { - private final transient AbstractAltrmiFactory mAltrmiFactory; - private final transient AltrmiClientInvocationHandler mClientInvocationHandler; - private final transient String mPublishedServiceName; - private final transient String mObjectName; - private final transient Long mReferenceID; - private final transient Long mSession; + private final transient AbstractAltrmiFactory m_altrmiFactory; + private final transient AltrmiClientInvocationHandler m_clientInvocationHandler; + private final transient String m_publishedServiceName; + private final transient String m_objectName; + private final transient Long m_referenceID; + private final transient Long m_session; /** @@ -63,12 +65,12 @@ Long session ) { - mAltrmiFactory = altrmiFactory; - mClientInvocationHandler = clientInvocationHandler; - mPublishedServiceName = pubishedServiceName; - mObjectName = objectName; - mReferenceID = referenceID; - mSession = session; + m_altrmiFactory = altrmiFactory; + m_clientInvocationHandler = clientInvocationHandler; + m_publishedServiceName = pubishedServiceName; + m_objectName = objectName; + m_referenceID = referenceID; + m_session = session; } /** @@ -80,7 +82,7 @@ */ public void registerImplObject( Object implBean ) { - mAltrmiFactory.registerReferenceObject( implBean, mReferenceID ); + m_altrmiFactory.registerReferenceObject( implBean, m_referenceID ); } /** @@ -109,18 +111,18 @@ if( arrayRetVal ) { - request = new MethodFacadeRequest( mPublishedServiceName, mObjectName, - methodSignature, args, mReferenceID, - objNameWithoutArray, mSession ); + request = new MethodFacadeRequest( m_publishedServiceName, m_objectName, + methodSignature, args, m_referenceID, + objNameWithoutArray, m_session ); } else { - request = new MethodFacadeRequest( mPublishedServiceName, mObjectName, - methodSignature, args, mReferenceID, objectName, - mSession ); + request = new MethodFacadeRequest( m_publishedServiceName, m_objectName, + methodSignature, args, m_referenceID, objectName, + m_session ); } - AltrmiReply reply = mClientInvocationHandler.handleInvocation( request ); + AltrmiReply reply = m_clientInvocationHandler.handleInvocation( request ); if( reply.getReplyCode() == AltrmiReplyConstants.METHODFACADEREPLY ) { @@ -133,18 +135,18 @@ return null; } - Object implBean = mAltrmiFactory.getImplObj( ref ); + Object implBean = m_altrmiFactory.getImplObj( ref ); if( implBean == null ) { - DefaultProxyHelper pHelper = new DefaultProxyHelper( mAltrmiFactory, - mClientInvocationHandler, - mPublishedServiceName, + DefaultProxyHelper pHelper = new DefaultProxyHelper( m_altrmiFactory, + m_clientInvocationHandler, + m_publishedServiceName, mfr.getObjectName(), ref, - mSession ); - Object retFacade = mAltrmiFactory.getInstance( mPublishedServiceName, + m_session ); + Object retFacade = m_altrmiFactory.getInstance( m_publishedServiceName, mfr.getObjectName(), pHelper, - mAltrmiFactory.isBeanOnly() ); + m_altrmiFactory.isBeanOnly() ); pHelper.registerImplObject( retFacade ); @@ -172,24 +174,24 @@ } else { - Object o = mAltrmiFactory.getImplObj( ref ); + Object o = m_altrmiFactory.getImplObj( ref ); implBeans[ i ] = o; if( implBeans[ i ] == null ) { - DefaultProxyHelper bo2 = new DefaultProxyHelper( mAltrmiFactory, - mClientInvocationHandler, - mPublishedServiceName, + DefaultProxyHelper bo2 = new DefaultProxyHelper( m_altrmiFactory, + m_clientInvocationHandler, + m_publishedServiceName, objectNames[ i ], refs[ i ], - mSession ); + m_session ); Object retFacade = null; try { - retFacade = mAltrmiFactory.getInstance( mPublishedServiceName, + retFacade = m_altrmiFactory.getInstance( m_publishedServiceName, objectNames[ i ], bo2, - mAltrmiFactory.isBeanOnly() ); + m_altrmiFactory.isBeanOnly() ); } catch( Exception e ) { @@ -236,11 +238,11 @@ public Object processObjectRequest( String methodSignature, Object[] args, Class[] argClasses ) throws Throwable { - mAltrmiFactory.marshallCorrection( methodSignature, args, argClasses ); + m_altrmiFactory.marshallCorrection( methodSignature, args, argClasses ); - MethodRequest request = new MethodRequest( mPublishedServiceName, mObjectName, - methodSignature, args, mReferenceID, mSession ); - AltrmiReply reply = mClientInvocationHandler.handleInvocation( request ); + MethodRequest request = new MethodRequest( m_publishedServiceName, m_objectName, + methodSignature, args, m_referenceID, m_session ); + AltrmiReply reply = m_clientInvocationHandler.handleInvocation( request ); if( reply.getReplyCode() == AltrmiReplyConstants.METHODREPLY ) { @@ -261,13 +263,16 @@ } } - public void processVoidRequests(RawRequest[] requests) throws Throwable + public void processVoidRequests(Vector requests) throws Throwable { - MethodAsyncRequest request = new MethodAsyncRequest( mPublishedServiceName, mObjectName, - requests, mReferenceID, mSession ); + + RawRequest[] rawRequests = new RawRequest[requests.size()]; + requests.copyInto(rawRequests); + MethodAsyncRequest request = new MethodAsyncRequest( m_publishedServiceName, m_objectName, + rawRequests, m_referenceID, m_session ); //debug(args); - AltrmiReply reply = mClientInvocationHandler.handleInvocation( request ); + AltrmiReply reply = m_clientInvocationHandler.handleInvocation( request ); if( reply.getReplyCode() == AltrmiReplyConstants.METHODREPLY ) { @@ -301,11 +306,11 @@ public void processVoidRequest( String methodSignature, Object[] args ) throws Throwable { - MethodRequest request = new MethodRequest( mPublishedServiceName, mObjectName, - methodSignature, args, mReferenceID, mSession ); + MethodRequest request = new MethodRequest( m_publishedServiceName, m_objectName, + methodSignature, args, m_referenceID, m_session ); //debug(args); - AltrmiReply reply = mClientInvocationHandler.handleInvocation( request ); + AltrmiReply reply = m_clientInvocationHandler.handleInvocation( request ); if( reply.getReplyCode() == AltrmiReplyConstants.METHODREPLY ) { @@ -388,9 +393,9 @@ // this checks the factory because reference IDs should not be // given out to any requester. It should be privileged information. - if( factory == mAltrmiFactory ) + if( factory == m_altrmiFactory ) { - return mReferenceID; + return m_referenceID; } else { @@ -401,13 +406,13 @@ protected void finalize() throws Throwable { - synchronized( mAltrmiFactory ) + synchronized( m_altrmiFactory ) { AltrmiReply reply = - mClientInvocationHandler - .handleInvocation( new GarbageCollectionRequest( mPublishedServiceName, - mObjectName, mSession, - mReferenceID ) ); + m_clientInvocationHandler + .handleInvocation( new GarbageCollectionRequest( m_publishedServiceName, + m_objectName, m_session, + m_referenceID ) ); if (reply instanceof ExceptionReply) { // This happens if the object can not be GCed on the remote server // for any reason. 1.2 +53 -1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/RawRequest.java Index: RawRequest.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/common/RawRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RawRequest.java 25 Nov 2002 21:17:07 -0000 1.1 +++ RawRequest.java 26 Nov 2002 06:09:55 -0000 1.2 @@ -1,13 +1,65 @@ +/* + * 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; -public class RawRequest +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +/** + * Class RawRequest + * + * + * @author Paul Hammant + * @version $Revision$ + */ +public class RawRequest extends AltrmiRequest { private String m_methodSignature; private Object[] m_args; + public RawRequest() + { + } + public RawRequest(String methodSignature, Object[] args) { m_methodSignature = methodSignature; m_args = args; } + + public String getMethodSignature() + { + return m_methodSignature; + } + + public Object[] getArgs() + { + return m_args; + } + + public int getRequestCode() + { + return AltrmiRequestConstants.METHODASYNCREQUEST; + } + + public void writeExternal( ObjectOutput out ) throws IOException + { + super.writeExternal( out ); + out.writeObject( m_methodSignature ); + out.writeObject( m_args ); + } + + public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException + { + super.readExternal( in ); + m_methodSignature = (String)in.readObject(); + m_args = (Object[]) in.readObject(); + } + } 1.15 +29 -14 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ProxyGeneratorImpl.java 25 Nov 2002 21:17:07 -0000 1.14 +++ ProxyGeneratorImpl.java 26 Nov 2002 06:09:55 -0000 1.15 @@ -151,7 +151,7 @@ m_classSource.print( "public class AltrmiGenerated" + getGenName() + "_" + name ); m_classSource.println( " implements org.apache.excalibur.altrmi.client.AltrmiProxy{ " ); m_classSource.println( - " private transient org.apache.excalibur.altrmi.client.ProxyHelper mProxyHelper;" ); + " private transient org.apache.excalibur.altrmi.client.ProxyHelper m_proxyHelper;" ); if (needsAsyncBehavior(interfacesToExpose)) { @@ -164,7 +164,7 @@ m_classSource.println( " public AltrmiGenerated" + getGenName() + "_" + name + " (org.apache.excalibur.altrmi.client.ProxyHelper proxyHelper) {" ); - m_classSource.println( " mProxyHelper = proxyHelper;" ); + m_classSource.println( " m_proxyHelper = proxyHelper;" ); m_classSource.println( " }" ); // helper method for the factory. @@ -172,7 +172,7 @@ m_classSource .println( " public Long altrmiGetReferenceID(Object factoryThatIsAsking) {" ); m_classSource - .println( " return mProxyHelper.getReferenceID(factoryThatIsAsking);" ); + .println( " return m_proxyHelper.getReferenceID(factoryThatIsAsking);" ); m_classSource.println( " }" ); makeSourceInterfaces(interfacesToExpose, methodsDone); @@ -278,7 +278,7 @@ else if (commit) { generateAsyncMethodBody(argTypes, rClass, methodSignature, method); - generateAsyncCommitMethodBody(argTypes, rClass, methodSignature, method); + generateAsyncCommitMethodBody(); } else if (rollback) { @@ -291,11 +291,6 @@ 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; @@ -305,7 +300,7 @@ if( rClass.equals( "void" ) ) { - m_classSource.println( " mProxyHelper.processVoidRequest(\"" + m_classSource.println( " m_proxyHelper.processVoidRequest(\"" + methodSignature.toString() + "\",args);" ); } else @@ -352,10 +347,30 @@ 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(\"" + m_classSource.println( " m_asyncInvocations.add(new org.apache.excalibur.altrmi.common.RawRequest(\"" + methodSignature + "\", args));" ); } + private void generateAsyncCommitMethodBody() + { + m_classSource.println( " try {" ); + + m_classSource.println( " m_proxyHelper.processVoidRequests(m_asyncInvocations);" ); + m_classSource.println( " } catch (Throwable t) {" ); + m_classSource.println( " if (t instanceof RuntimeException) { " ); + m_classSource.println( " throw (RuntimeException) t;" ); + m_classSource.println( " } else if (t instanceof Error) { " ); + m_classSource.println( " throw (Error) t;" ); + m_classSource.println( " } else { " ); + m_classSource.println( " t.printStackTrace(); " ); + m_classSource.println( + " throw new org.apache.excalibur.altrmi.common." + + "AltrmiInvocationException(\"Should never get here: \" +t.getMessage());"); + m_classSource.println( " }" ); + m_classSource.println( " }" ); + + } + private void makeSourceInterfacesMethodsNotDoneNotVoid(Method method, Class rClass, String methodSignature) @@ -371,7 +386,7 @@ } m_classSource.println( - " Object retVal = mProxyHelper.processObjectRequestGettingFacade(" + " Object retVal = m_proxyHelper.processObjectRequestGettingFacade(" + retClassType.getName() + ".class , \"" + methodSignature.toString() + "\",args,\"" + MethodNameHelper.encodeClassName( getClassType( rClass ) ) + "\");" ); @@ -381,7 +396,7 @@ else { m_classSource.println( - " Object retVal = mProxyHelper.processObjectRequest(\"" + " Object retVal = m_proxyHelper.processObjectRequest(\"" + methodSignature.toString() + "\",args,argClasses);" ); generateReturnLine( rClass ); } 1.3 +44 -5 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PublicationDescriptionItem.java 25 Nov 2002 21:17:08 -0000 1.2 +++ PublicationDescriptionItem.java 26 Nov 2002 06:09:55 -0000 1.3 @@ -34,20 +34,26 @@ m_rollbackMethod = null; } - public PublicationDescriptionItem(Class facadeClass, String[] asyncMethods) + public PublicationDescriptionItem(Class facadeClass, String[] asyncMethods) throws PublicationException { - this.m_facadeClass = facadeClass; + m_facadeClass = facadeClass; if (facadeClass == null) { throw new RuntimeException("Facade class nust not be null"); } - this.m_asyncMethods = asyncMethods; + m_asyncMethods = asyncMethods; + for (int i = 0; i < asyncMethods.length; i++) + { + String asyncMethod = asyncMethods[i]; + testMethodType(facadeClass.getMethods(), asyncMethod); + + } m_commitMethod = null; m_rollbackMethod = null; } public PublicationDescriptionItem(Class facadeClass, String[] asyncMethods, - String commitMethod, String rollbackMethod) + String commitMethod, String rollbackMethod) throws PublicationException { m_facadeClass = facadeClass; if (facadeClass == null) @@ -57,7 +63,40 @@ m_asyncMethods = asyncMethods; m_commitMethod = commitMethod; m_rollbackMethod = rollbackMethod; + for (int i = 0; i < asyncMethods.length; i++) + { + String asyncMethod = asyncMethods[i]; + testMethodType(facadeClass.getMethods(), asyncMethod); + + } + testMethodType(facadeClass.getMethods(), commitMethod); + testMethodType(facadeClass.getMethods(), rollbackMethod); } + + private void testMethodType(Method[] methods, String methodSignature) throws PublicationException + { + for (int i = 0; i < methods.length; i++) + { + Method method = methods[i]; + if (MethodNameHelper.getMethodSignature(method).equals(methodSignature)) + { + if (method.getReturnType().toString().equals("void") != true) + { + throw new PublicationException("Only 'void' returning methods are " + + "eligible for asynchronous methods."); + } + + Class[] exceptions = method.getExceptionTypes(); + + if (exceptions.length != 0) + { + throw new PublicationException("Only methods without exceptions " + + "are eligible for asynchronous behavior "); + } + } + } + } + public Class getFacadeClass() { 1.9 +3 -1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java Index: StreamServerConnection.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/StreamServerConnection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- StreamServerConnection.java 28 Oct 2002 21:58:56 -0000 1.8 +++ StreamServerConnection.java 26 Nov 2002 06:09:55 -0000 1.9 @@ -20,6 +20,8 @@ import org.apache.excalibur.altrmi.common.BadConnectionException; import org.apache.excalibur.altrmi.server.AltrmiServerConnection; +import javax.swing.*; + /** * Class StreamServerConnection * 1.14 +52 -11 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.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- InvocationHandlerAdapter.java 25 Nov 2002 21:17:08 -0000 1.13 +++ InvocationHandlerAdapter.java 26 Nov 2002 06:09:55 -0000 1.14 @@ -43,6 +43,8 @@ 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.common.MethodAsyncRequest; +import org.apache.excalibur.altrmi.common.RawRequest; import org.apache.excalibur.altrmi.server.AltrmiAuthenticator; import org.apache.excalibur.altrmi.server.ClassRetrievalException; import org.apache.excalibur.altrmi.server.ClassRetriever; @@ -52,6 +54,8 @@ import org.apache.excalibur.altrmi.server.impl.DefaultMethodInvocationHandler; import org.apache.excalibur.altrmi.server.impl.classretrievers.NoClassRetriever; +import javax.swing.*; + /** * Class InvocationHandlerAdapter * @@ -124,6 +128,11 @@ return doMethodFacadeRequest( request ); } + else if( request.getRequestCode() == AltrmiRequestConstants.METHODASYNCREQUEST ) + { + return doMethodAsyncRequest( (MethodAsyncRequest) request ); + + } else if( request.getRequestCode() == AltrmiRequestConstants.GCREQUEST ) { return doGarbageCollectionRequest( request ); @@ -172,16 +181,16 @@ */ private AltrmiReply doMethodFacadeRequest( AltrmiRequest request ) { - MethodFacadeRequest mFacReq = (MethodFacadeRequest)request; - String publishedThing = mFacReq.getPublishedServiceName() + "_" - + mFacReq.getObjectName(); + MethodFacadeRequest facadeRequest = (MethodFacadeRequest)request; + String publishedThing = facadeRequest.getPublishedServiceName() + "_" + + facadeRequest.getObjectName(); if( !isPublished( publishedThing ) ) { return new NotPublishedReply(); } - if( !sessionExists( mFacReq.getSession() ) ) + if( !sessionExists( facadeRequest.getSession() ) ) { return new ExceptionReply( new AltrmiInvocationException( "TODO - you dirty rat/hacker" ) ); @@ -189,7 +198,7 @@ MethodInvocationHandler methodInvocationHandler = getMethodInvocationHandler( publishedThing ); - AltrmiReply ar = methodInvocationHandler.handleMethodInvocation( mFacReq ); + AltrmiReply ar = methodInvocationHandler.handleMethodInvocation( facadeRequest ); if( ar.getReplyCode() == AltrmiReplyConstants.EXCEPTIONREPLY ) { @@ -209,11 +218,11 @@ } else if( !methodReply.getClass().isArray() ) { - return doMethodFacadeRequestNonArray( methodReply, mFacReq ); + return doMethodFacadeRequestNonArray( methodReply, facadeRequest ); } else { - return doMethodFacadeRequestArray( methodReply, mFacReq ); + return doMethodFacadeRequestArray( methodReply, facadeRequest ); } } @@ -330,8 +339,8 @@ */ private AltrmiReply doMethodRequest( AltrmiRequest request ) { - MethodRequest mReq = (MethodRequest)request; - String publishedThing = mReq.getPublishedServiceName() + "_" + mReq.getObjectName(); + MethodRequest methodRequest = (MethodRequest)request; + String publishedThing = methodRequest.getPublishedServiceName() + "_" + methodRequest.getObjectName(); if( !isPublished( publishedThing ) ) { @@ -341,8 +350,40 @@ MethodInvocationHandler methodInvocationHandler = getMethodInvocationHandler( publishedThing ); - return methodInvocationHandler.handleMethodInvocation( mReq ); + return methodInvocationHandler.handleMethodInvocation( methodRequest ); } + + private AltrmiReply doMethodAsyncRequest(MethodAsyncRequest methodRequest) + { + String publishedThing = methodRequest.getPublishedServiceName() + "_" + methodRequest.getObjectName(); + + if( !isPublished( publishedThing ) ) + { + return new NotPublishedReply(); + } + + MethodInvocationHandler methodInvocationHandler = + getMethodInvocationHandler( publishedThing ); + + RawRequest[] requests = methodRequest.getRawRequests(); + for (int i = 0; i < requests.length; i++) + { + RawRequest rawRequest = requests[i]; + methodInvocationHandler.handleMethodInvocation( + new MethodRequest( + methodRequest.getPublishedServiceName(), + methodRequest.getObjectName(), + rawRequest.getMethodSignature(), + rawRequest.getArgs(), + methodRequest.getReferenceID(), + methodRequest.getSession()) + ); + } + + return new MethodReply(); + + } + /** * DO a lokkup request 1.4 +3 -1 jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/MarshalledInvocationHandlerAdapter.java Index: MarshalledInvocationHandlerAdapter.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/adapters/MarshalledInvocationHandlerAdapter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MarshalledInvocationHandlerAdapter.java 26 Sep 2002 06:23:54 -0000 1.3 +++ MarshalledInvocationHandlerAdapter.java 26 Nov 2002 06:09:55 -0000 1.4 @@ -14,6 +14,8 @@ import org.apache.excalibur.altrmi.common.AltrmiRequest; import org.apache.excalibur.altrmi.common.SerializationHelper; +import javax.swing.*; + /** * Class MarshalledInvocationHandlerAdapter * 1.3 +11 -4 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SimpleAsyncTestCase.java 25 Nov 2002 21:17:08 -0000 1.2 +++ SimpleAsyncTestCase.java 26 Nov 2002 06:09:55 -0000 1.3 @@ -49,9 +49,9 @@ new PublicationDescriptionItem(AsyncTest.class, new String[]{"setOne(java.lang.String)", "setTwo(java.lang.String)", - "setThree(java.lang.String)" - }//, - // "fire()", null + "setThree(java.lang.String)", + }, + "fire()", null ) ); cr.generate("AsyncTest",pd, this.getClass().getClassLoader()); @@ -88,7 +88,6 @@ assertNotNull("Field 'Tree' should not be null", asyncTestImpl.three); assertTrue("Field 'Fire' should not be false", asyncTestImpl.fired); - } @@ -104,6 +103,14 @@ server = null; asyncTestImpl = null; super.tearDown(); + } + + public static void main(String[] args) throws Exception + { + SimpleAsyncTestCase simp = new SimpleAsyncTestCase("testSimpleAsync"); + simp.setUp(); + simp.testSimpleAsync(); + simp.tearDown(); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>