You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ha...@apache.org on 2002/02/01 01:16:38 UTC
cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test TestClient.java TestInterface.java TestInterfaceImpl.java
hammant 02/01/31 16:16:38
Modified: altrmi/src/java/org/apache/commons/altrmi/client/impl
AbstractAltrmiFactory.java BaseServedObject.java
ServerClassAltrmiFactory.java
altrmi/src/java/org/apache/commons/altrmi/common
AltrmiReply.java MethodFacadeRequest.java
altrmi/src/java/org/apache/commons/altrmi/generator
ProxyGeneratorImpl.java
altrmi/src/java/org/apache/commons/altrmi/server/impl
DefaultMethodInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters
InovcationHandlerAdapter.java
altrmi/src/java/org/apache/commons/altrmi/test
TestClient.java TestInterface.java
TestInterfaceImpl.java
Added: altrmi/src/java/org/apache/commons/altrmi/client
AltrmiProxy.java
altrmi/src/java/org/apache/commons/altrmi/common
MethodFacadeArrayReply.java
Log:
alternate facades can be arrays in return types
Revision Changes Path
1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/AltrmiProxy.java
Index: AltrmiProxy.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.commons.altrmi.client;
/**
* Interface AltrmiProxy
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public interface AltrmiProxy {
}
1.12 +2 -14 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java
Index: AbstractAltrmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AbstractAltrmiFactory.java 30 Jan 2002 23:42:44 -0000 1.11
+++ AbstractAltrmiFactory.java 1 Feb 2002 00:16:38 -0000 1.12
@@ -31,7 +31,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public abstract class AbstractAltrmiFactory implements AltrmiFactory {
@@ -48,6 +48,7 @@
*
*
* @param beanOnly
+ * @param classLoader
*
*/
public AbstractAltrmiFactory(boolean beanOnly, ClassLoader classLoader) {
@@ -95,19 +96,6 @@
}
}
- /**
- * Method getInstance
- *
- *
- * @param publishedServiceName
- * @param String objectName
- * @param BaseServedObject baseServedObject
- *
- * @return
- *
- * @throws AltrmiConnectionException
- *
- */
protected abstract Object getInstance(
String publishedServiceName, String objectName, BaseServedObject baseServedObject,
boolean beanOnly) throws AltrmiConnectionException;
1.7 +47 -4 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java
Index: BaseServedObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseServedObject.java 17 Jan 2002 12:14:28 -0000 1.6
+++ BaseServedObject.java 1 Feb 2002 00:16:38 -0000 1.7
@@ -20,6 +20,9 @@
import org.apache.commons.altrmi.common.MethodFacadeReply;
import org.apache.commons.altrmi.common.MethodFacadeRequest;
import org.apache.commons.altrmi.common.FacadeRefHolder;
+import org.apache.commons.altrmi.common.MethodFacadeArrayReply;
+
+import java.lang.reflect.Array;
/**
@@ -27,7 +30,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public final class BaseServedObject {
@@ -90,9 +93,21 @@
public Object altrmiProcessObjectRequestGettingFacade(
String methodSignature, Object[] args, String objectName) throws Throwable {
- MethodFacadeRequest request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
- methodSignature, args,
- mReferenceID, objectName, mSession);
+ boolean arrayRetVal = objectName.endsWith("[]");
+ String objNameWithoutArray = objectName.substring(0,objectName.length()-2);
+
+ MethodFacadeRequest request;
+
+ if (arrayRetVal) {
+ request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
+ methodSignature, args, mReferenceID,
+ objNameWithoutArray, mSession);
+ } else {
+ request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
+ methodSignature, args, mReferenceID,
+ objectName, mSession);
+ }
+
AltrmiReply reply = mInvocationHandler.handleInvocation(request);
if (reply.getReplyCode() == AltrmiReply.METHODFACADEREPLY) {
@@ -113,6 +128,34 @@
} else {
return implBean;
}
+ } else if (reply.getReplyCode() == AltrmiReply.METHODFACADEARRAYREPLY) {
+ MethodFacadeArrayReply mfar = (MethodFacadeArrayReply) reply;
+ Class clazz = Class.forName(objNameWithoutArray.replace('$','.'));
+ Long[] refs = mfar.getReferenceIDs();
+ Object[] implBeans = (Object[]) Array.newInstance(clazz, refs.length);
+
+ for (int i = 0; i < refs.length; i++) {
+ Long ref = refs[i];
+ implBeans[i] = mAltrmiFactory.getImplObj(refs[i]);
+ if (implBeans[i] == null) {
+ BaseServedObject bo2 = new BaseServedObject(mAltrmiFactory, mInvocationHandler,
+ mPublishedServiceName, objNameWithoutArray,
+ refs[i], mSession);
+ Object retFacade = null;
+ try {
+ retFacade = mAltrmiFactory.getInstance(mPublishedServiceName, objNameWithoutArray,
+ bo2, mAltrmiFactory.isBeanOnly());
+ } catch (Exception e) {
+ System.out.println("objNameWithoutArray=" + objNameWithoutArray);
+ System.out.flush();
+ e.printStackTrace();
+ }
+
+ bo2.registerImplObject(retFacade);
+ implBeans[i] = retFacade;
+ }
+ }
+ return implBeans;
} else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
ExceptionReply er = (ExceptionReply) reply;
1.10 +17 -18 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java
Index: ServerClassAltrmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ServerClassAltrmiFactory.java 30 Jan 2002 23:42:44 -0000 1.9
+++ ServerClassAltrmiFactory.java 1 Feb 2002 00:16:38 -0000 1.10
@@ -36,7 +36,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
@@ -53,9 +53,16 @@
super(beanOnly, ServerClassAltrmiFactory.class.getClassLoader());
}
+ /**
+ * Constructor ServerClassAltrmiFactory
+ *
+ *
+ * @param beanOnly
+ * @param classLoader
+ *
+ */
public ServerClassAltrmiFactory(boolean beanOnly, ClassLoader classLoader) {
super(beanOnly, classLoader);
- System.out.println("NEWWWWW SCAF " + classLoader);
}
/**
@@ -75,7 +82,8 @@
AltrmiReply ar =
mHostContext.getInvocationHandler()
- .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication, mSession));
+ .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication,
+ mSession));
if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
if (ar instanceof NotPublishedReply) {
@@ -102,21 +110,8 @@
return retVal;
}
- /**
- * Method getInstance
- *
- *
- * @param publishedServiceName
- * @param objectName
- *
- * @return
- *
- * @throws AltrmiConnectionException
- *
- */
protected Object getInstance(
- String publishedServiceName, String objectName,
- BaseServedObject baseServedObject, boolean beanOnly)
+ String publishedServiceName, String objectName, BaseServedObject baseServedObject, boolean beanOnly)
throws AltrmiConnectionException {
String code = "2";
@@ -147,8 +142,9 @@
.getFailureReason());
} else if (ar instanceof ClassRetrievalFailedReply) {
ClassRetrievalFailedReply crfr = (ClassRetrievalFailedReply) ar;
+
throw new AltrmiConnectionException("Exception on server side ");
- } //TODO others.
+ } //TODO others.
}
cr = (ClassReply) ar;
@@ -163,6 +159,7 @@
try {
byte[] bytes = cr.getInterfaceImplClassBytes();
+
tcl.add(iiClassName, bytes);
} catch (NoClassDefFoundError ncdfe) {
@@ -189,6 +186,7 @@
System.out.println("---**");
cnfe.getException().printStackTrace();
System.out.println("---**");
+
throw new AltrmiConnectionException("Generated class not found during lookup : "
+ cnfe.getMessage());
} catch (InstantiationException ie) {
@@ -199,6 +197,7 @@
"Illegal access to generated class during lookup : " + iae.getMessage());
}
}
+
/**
* Method close
*
1.7 +2 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java
Index: AltrmiReply.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AltrmiReply.java 29 Jan 2002 10:15:56 -0000 1.6
+++ AltrmiReply.java 1 Feb 2002 00:16:38 -0000 1.7
@@ -21,7 +21,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
public abstract class AltrmiReply implements Externalizable {
@@ -34,6 +34,7 @@
public static final int OPENCONNECTIONREPLY = 6;
public static final int PINGREPLY = 7;
public static final int LISTREPLY=8;
+ public static final int METHODFACADEARRAYREPLY = 9;
// 'bad' replies after 100
1.4 +8 -8 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeRequest.java
Index: MethodFacadeRequest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeRequest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MethodFacadeRequest.java 18 Jan 2002 11:03:20 -0000 1.3
+++ MethodFacadeRequest.java 1 Feb 2002 00:16:38 -0000 1.4
@@ -20,11 +20,11 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public final class MethodFacadeRequest extends MethodRequest {
- private String mReturnClassNameEncoded;
+ private String mBaseReturnClassNameEncoded;
/**
* Constructor MethodFacadeRequest
@@ -41,11 +41,11 @@
*/
public MethodFacadeRequest(String publishedServiceName, String objectName,
String methodSignature, Object[] args, Long referenceID,
- String returnClassNameEncoded, Long session) {
+ String baseReturnClassNameEncoded, Long session) {
super(publishedServiceName, objectName, methodSignature, args, referenceID, session);
- mReturnClassNameEncoded = returnClassNameEncoded;
+ mBaseReturnClassNameEncoded = baseReturnClassNameEncoded;
}
/**
@@ -73,8 +73,8 @@
* @return
*
*/
- public String getReturnClassNameEncoded() {
- return mReturnClassNameEncoded;
+ public String getBaseReturnClassNameEncoded() {
+ return mBaseReturnClassNameEncoded;
}
/**
@@ -94,7 +94,7 @@
*/
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
- out.writeObject(mReturnClassNameEncoded);
+ out.writeObject(mBaseReturnClassNameEncoded);
}
/**
@@ -113,6 +113,6 @@
super.readExternal(in);
- mReturnClassNameEncoded = (String) in.readObject();
+ mBaseReturnClassNameEncoded = (String) in.readObject();
}
}
1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeArrayReply.java
Index: MethodFacadeArrayReply.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.commons.altrmi.common;
import java.io.ObjectOutput;
import java.io.IOException;
import java.io.ObjectInput;
/**
* Class MethodFacadeReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public final class MethodFacadeArrayReply extends AltrmiReply {
private Long[] mReferenceIDs;
/**
* Constructor MethodFacadeReply
*
*
* @param referenceID
*
*/
public MethodFacadeArrayReply(Long[] referenceIDs) {
mReferenceIDs = referenceIDs;
}
/**
* Constructor MethodFacadeReply
*
*
*/
public MethodFacadeArrayReply() {} // for Externalization
/**
* Method getReference
*
*
* @return
*
*/
public Long[] getReferenceIDs() {
return mReferenceIDs;
}
/**
* Method getReplyCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getReplyCode() {
return METHODFACADEARRAYREPLY;
}
/**
* 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 {
out.writeObject(mReferenceIDs);
}
/**
* 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 {
mReferenceIDs = (Long[]) in.readObject();
}
}
1.2 +19 -7 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ProxyGeneratorImpl.java
Index: ProxyGeneratorImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ProxyGeneratorImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ProxyGeneratorImpl.java 30 Jan 2002 23:42:44 -0000 1.1
+++ ProxyGeneratorImpl.java 1 Feb 2002 00:16:38 -0000 1.2
@@ -32,7 +32,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 ProxyGeneratorImpl extends AbstractMethodHandler implements ProxyGenerator {
@@ -159,7 +159,7 @@
}
mClassSource.print("public class AltrmiGenerated" + mGenName + "_" + name);
- mClassSource.println(" { ");
+ mClassSource.println(" implements org.apache.commons.altrmi.client.AltrmiProxy{ ");
mClassSource.println(
" private transient org.apache.commons.altrmi.client.impl.BaseServedObject mBaseServedObject;");
mClassSource.println(
@@ -234,8 +234,10 @@
mClassSource.println(
" Object retVal = mBaseServedObject.altrmiProcessObjectRequestGettingFacade(\""
+ methodSignature.toString() + "\",args,\""
- + encodeClassName(rClass.getName()) + "\");");
- mClassSource.println(" return (" + rClass.getName() + ") retVal;");
+ + encodeClassName(getClassType(rClass)) + "\");");
+ mClassSource.println(" return (" + getClassType(rClass) + ") retVal;");
+
+
} else {
mClassSource.println(
" Object retVal = mBaseServedObject.altrmiProcessObjectRequest(\""
@@ -257,8 +259,9 @@
mClassSource.println(" } else if (t instanceof Error) { ");
mClassSource.println(" throw (Error) t;");
mClassSource.println(" } else { ");
+ mClassSource.println(" t.printStackTrace(); ");
mClassSource.println(
- " throw new org.apache.commons.altrmi.common.AltrmiInvocationException(\"Should never get here\" + t.getMessage()); ");
+ " throw new org.apache.commons.altrmi.common.AltrmiInvocationException(\"Should never get here: \" + t.getMessage()); ");
mClassSource.println(" }");
mClassSource.println(" }");
mClassSource.println(" }");
@@ -408,7 +411,6 @@
private void generateReturnLine(Class rClass) {
- String arrayOtNot = rClass.isArray() ? "[]" : "";
String cn = rClass.getName();
if (cn.equals("boolean")) {
@@ -452,6 +454,15 @@
}
}
+ private String getClassType(Class rClass) {
+ String cn = rClass.getName();
+ if (rClass.getName().startsWith("[L")) {
+ return cn.substring(2,cn.length()-1) + "[]";
+ } else {
+ return cn;
+ }
+ }
+
private String generateReturnValue(Class rClass) {
String cn = rClass.getName();
if (cn.equals("[B")) {
@@ -487,9 +498,10 @@
for (int p = 0; p < mAdditionalFacades.length; p++) {
if (clazz.equals(mAdditionalFacades[p])) {
return true;
+ } else if (clazz.getName().equals("[L" + mAdditionalFacades[p].getName() + ";")) {
+ return true;
}
}
-
return false;
}
}
1.2 +4 -2 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultMethodInvocationHandler.java
Index: DefaultMethodInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultMethodInvocationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultMethodInvocationHandler.java 29 Jan 2002 10:05:00 -0000 1.1
+++ DefaultMethodInvocationHandler.java 1 Feb 2002 00:16:38 -0000 1.2
@@ -21,6 +21,7 @@
import org.apache.commons.altrmi.common.FacadeRefHolder;
import org.apache.commons.altrmi.server.MethodInvocationHandler;
import org.apache.commons.altrmi.server.AltrmiPublisher;
+import org.apache.commons.altrmi.client.AltrmiProxy;
import java.util.HashMap;
import java.util.Iterator;
@@ -37,7 +38,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 DefaultMethodInvocationHandler implements MethodInvocationHandler {
@@ -166,7 +167,8 @@
correctArgs(mr, args);
- return new MethodReply(method.invoke(beanImpl, mr.getArgs()));
+ Object replyVal = method.invoke(beanImpl, mr.getArgs());
+ return new MethodReply(replyVal);
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
1.5 +53 -24 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters/InovcationHandlerAdapter.java
Index: InovcationHandlerAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters/InovcationHandlerAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InovcationHandlerAdapter.java 29 Jan 2002 10:15:56 -0000 1.4
+++ InovcationHandlerAdapter.java 1 Feb 2002 00:16:38 -0000 1.5
@@ -31,6 +31,7 @@
import org.apache.commons.altrmi.common.OpenConnectionReply;
import org.apache.commons.altrmi.common.PingReply;
import org.apache.commons.altrmi.common.ListReply;
+import org.apache.commons.altrmi.common.MethodFacadeArrayReply;
import org.apache.commons.altrmi.server.AltrmiServer;
import org.apache.commons.altrmi.server.MethodInvocationHandler;
import org.apache.commons.altrmi.server.ClassRetrievalException;
@@ -50,7 +51,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class InovcationHandlerAdapter extends PublicationAdapter
implements AltrmiInvocationHandler {
@@ -102,8 +103,8 @@
// Method request is positionid first as
// it is the one we want to be most speedy.
if (request.getRequestCode() == AltrmiRequest.METHODREQUEST) {
- MethodRequest mr = (MethodRequest) request;
- String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
+ MethodRequest mReq = (MethodRequest) request;
+ String publishedThing = mReq.getPublishedServiceName() + "_" + mReq.getObjectName();
if (!mPublishedObjects.containsKey(publishedThing)) {
return new NotPublishedReply();
@@ -112,23 +113,23 @@
AltrmiInvocationHandler ih =
(AltrmiInvocationHandler) mPublishedObjects.get(publishedThing);
- return ih.handleInvocation(mr);
+ return ih.handleInvocation(mReq);
} else if (request.getRequestCode() == AltrmiRequest.METHODFACADEREQUEST) {
- MethodFacadeRequest mr = (MethodFacadeRequest) request;
- String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
+ MethodFacadeRequest mFacReq = (MethodFacadeRequest) request;
+ String publishedThing = mFacReq.getPublishedServiceName() + "_" + mFacReq.getObjectName();
if (!mPublishedObjects.containsKey(publishedThing)) {
return new NotPublishedReply();
}
- if (!sessionExists(mr.getSession())) {
+ if (!sessionExists(mFacReq.getSession())) {
return new ExceptionReply(
new AltrmiInvocationException("TODO - you dirty rat/hacker"));
}
MethodInvocationHandler asih =
(MethodInvocationHandler) mPublishedObjects.get(publishedThing);
- AltrmiReply ar = asih.handleInvocation(mr);
+ AltrmiReply ar = asih.handleInvocation(mFacReq);
if (ar.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
return ar;
@@ -138,26 +139,54 @@
return new RequestFailedReply("TODO");
}
- Object beanImpl = ((MethodReply) ar).getReplyObject();
- MethodInvocationHandler asih2 =
- (MethodInvocationHandler) mPublishedObjects.get(mr.getPublishedServiceName()
- + "_"
- + mr.getReturnClassNameEncoded());
+ Object replyObject = ((MethodReply) ar).getReplyObject();
- if (asih2 == null) {
- return new NotPublishedReply();
- }
+ if (!replyObject.getClass().isArray()) {
- if (!sessionExists(mr.getSession())) {
- return new ExceptionReply(
- new AltrmiInvocationException("TODO - you dirty rat/hacker"));
- }
+ Object beanImpl = replyObject;
+
+ MethodInvocationHandler asih2 =
+ (MethodInvocationHandler) mPublishedObjects.get(
+ mFacReq.getPublishedServiceName() + "_" + mFacReq.getBaseReturnClassNameEncoded());
+
+ if (asih2 == null) {
+ return new NotPublishedReply();
+ }
+
+ if (!sessionExists(mFacReq.getSession())) {
+ return new ExceptionReply(
+ new AltrmiInvocationException("TODO - you dirty rat/hacker"));
+ }
+
+ //TODO a decent ref number for main?
+ Long newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
+
+ //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
+ return new MethodFacadeReply(newRef);
+ } else {
+ Object[] beanImpls = (Object[]) replyObject;
+ Long[] refs = new Long[beanImpls.length];
+ for (int i = 0; i < beanImpls.length; i++) {
+ Object impl = beanImpls[i];
+ MethodInvocationHandler asih2 =
+ (MethodInvocationHandler) mPublishedObjects.get(
+ mFacReq.getPublishedServiceName() + "_" + mFacReq.getBaseReturnClassNameEncoded());
+
+ if (asih2 == null) {
+ return new NotPublishedReply();
+ }
+
+ if (!sessionExists(mFacReq.getSession())) {
+ return new ExceptionReply(
+ new AltrmiInvocationException("TODO - you dirty rat/hacker"));
+ }
- //TODO a decent ref number for main?
- Long newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
+ //TODO a decent ref number for main?
+ refs[i] = asih2.getOrMakeReferenceIDForBean(beanImpls[i]);
- //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
- return new MethodFacadeReply(newRef);
+ }
+ return new MethodFacadeArrayReply(refs);
+ }
} else if (request.getRequestCode() == AltrmiRequest.LOOKUPREQUEST) {
LookupRequest lr = (LookupRequest) request;
1.5 +10 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestClient.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestClient.java 17 Jan 2002 17:48:46 -0000 1.4
+++ TestClient.java 1 Feb 2002 00:16:38 -0000 1.5
@@ -23,7 +23,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class TestClient {
@@ -80,6 +80,15 @@
System.out.println("CLT: One (by finder) name = '" + ti2OneB.getName() + "'");
System.out.println("CLT: new object == (instance equality) to '111' obj ? -> "
+ (ti2One == ti2OneB));
+
+ System.out.println("CLT: Test array retval of 'Alternative Facades'..");
+
+ TestInterface2[] ti2s = ti.getTestInterface2s();
+
+ for (int i = 0; i < ti2s.length; i++) {
+ TestInterface2 ti2 = ti2s[i];
+ System.out.println("CLT: .. name["+i+"] = '" + ti2s[i].getName() + "'");
+ }
System.out.println("CLT: A test for bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html");
1.3 +10 -2 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestInterface.java
Index: TestInterface.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestInterface.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestInterface.java 16 Jan 2002 11:32:20 -0000 1.2
+++ TestInterface.java 1 Feb 2002 00:16:38 -0000 1.3
@@ -20,7 +20,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 interface TestInterface {
@@ -118,6 +118,15 @@
TestInterface2 findTestInterface2ByName(String nameToFind);
/**
+ * Method getTestInterface2s
+ *
+ *
+ * @return
+ *
+ */
+ TestInterface2[] getTestInterface2s();
+
+ /**
* Method getTestObjects
* Helps ilustrate the bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
*
@@ -140,5 +149,4 @@
*
*/
void makeNewTestObjectNames();
-
}
1.3 +21 -3 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestInterfaceImpl.java
Index: TestInterfaceImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/TestInterfaceImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestInterfaceImpl.java 16 Jan 2002 11:32:20 -0000 1.2
+++ TestInterfaceImpl.java 1 Feb 2002 00:16:38 -0000 1.3
@@ -22,7 +22,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 TestInterfaceImpl implements TestInterface {
@@ -178,6 +178,26 @@
}
/**
+ * Method getTestInterfaces
+ *
+ *
+ * @return
+ *
+ */
+ public TestInterface2[] getTestInterface2s() {
+
+ TestInterface2[] retVal = new TestInterface2[ti2Holder.size()];
+
+ for (int i = 0; i < ti2Holder.size(); i++) {
+ TestInterface2 interface2 = (TestInterface2) ti2Holder.elementAt(i);
+
+ retVal[i] = interface2;
+ }
+
+ return retVal;
+ }
+
+ /**
* Method getTestObjects
* Helps ilustrate the bug http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
*
@@ -186,7 +206,6 @@
*/
public TestObject[] getTestObjects() {
-
if (mTestObjects == null) {
mTestObjects = new TestObject[3];
mTestObjects[0] = new TestObject("AAA");
@@ -219,6 +238,5 @@
mTestObjects[0] = new TestObject("aAa");
mTestObjects[1] = new TestObject("bBb");
mTestObjects[2] = new TestObject("cCc");
-
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>