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/01/06 16:39:53 UTC
cvs commit: jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test TestInterface2.java TestInterface2Impl.java DirectTest.java PipeTest.java RmiClientTest.java RmiServerTest.java SocketClientTest.java SocketServerTest.java TestClient.java TestInterface.java TestInterfaceImpl.java
hammant 02/01/06 07:39:53
Modified: armi PROPOSAL test.xml
armi/src/java/org/apache/commons/armi/client
ArmiFactory.java
armi/src/java/org/apache/commons/armi/client/impl
AbstractArmiFactory.java BaseServedObject.java
ClientClassArmiFactory.java
ObjectStreamInvocationHandler.java
ServerClassArmiFactory.java
TransportedClassLoader.java
armi/src/java/org/apache/commons/armi/client/impl/direct
DirectArmiHostContext.java
DirectInvocationHandler.java
armi/src/java/org/apache/commons/armi/client/impl/rmi
RmiInvocationHandler.java
armi/src/java/org/apache/commons/armi/client/impl/socket
PlainSocketInvocationHandler.java
armi/src/java/org/apache/commons/armi/common
AbstractMethodHandler.java ArmiReply.java
ArmiRequest.java ClassRequest.java
MethodRequest.java NotPublishedException.java
PublishedNameRequest.java
armi/src/java/org/apache/commons/armi/generator
PrimarySourceGenerator.java
SecondarySourceGenerator.java
armi/src/java/org/apache/commons/armi/generator/ant
ArmiClassInternTask.java ArmiInterfaceTask.java
armi/src/java/org/apache/commons/armi/server ArmiServer.java
armi/src/java/org/apache/commons/armi/server/impl
AbstractServer.java DefaultInvocationHandler.java
armi/src/java/org/apache/commons/armi/test DirectTest.java
PipeTest.java RmiClientTest.java RmiServerTest.java
SocketClientTest.java SocketServerTest.java
TestClient.java TestInterface.java
TestInterfaceImpl.java
Added: armi/src/java/org/apache/commons/armi/common
LookupReply.java LookupRequest.java
MethodFacadeReply.java MethodFacadeRequest.java
NoSuchReferenceReply.java
NotSuchReferenceException.java
armi/src/java/org/apache/commons/armi/server
ArmiServerInvocationHandler.java
armi/src/java/org/apache/commons/armi/test
TestInterface2.java TestInterface2Impl.java
Log:
ARMI is now aware that its method return types can be
other ARMI facades.
Revision Changes Path
1.12 +14 -9 jakarta-commons-sandbox/armi/PROPOSAL
Index: PROPOSAL
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/PROPOSAL,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PROPOSAL 4 Jan 2002 13:15:30 -0000 1.11
+++ PROPOSAL 6 Jan 2002 15:39:51 -0000 1.12
@@ -82,19 +82,24 @@
- The server implements and acts upon start() and stop() methods.
-Limitations:
+12) No just pass by value.
-1) Pass by value only.
+ - ARMI started life as 'pass by value' only. In now support return
+ types wrapped in another ARMI Facade.
+
- - Unlike proper RMI, ARMI only currently supports "pass by value". If
- an argument or return type were another ARMI published service, then
- it could not currently be handled by ARMI. (to fix).
-
-2) Use in EJB
+Limitations:
+
+1) Use in EJB
- This is not of any use for EJB Home/Remote interfaces. The container
maker chooses the transport for use that container, not the bean coder.
- This is intended for other client server solutions.
+ This is intended for other client server solutions. Beside RMI over IIOP
+ is Sun specified.
+
+2) Method Params must not be other ARMI Facades.
+
+ - To fix.
Todo:
@@ -107,7 +112,7 @@
2) Generated classes from getResource() from jars on the serverside as an
alternative to the byte arrays in the current server side impl.
-3) Clint and Server code for secure conversations.
+3) Client and Server code for secure conversations.
4) Authentication and Authorisation on lookup(..).
1.6 +6 -4 jakarta-commons-sandbox/armi/test.xml
Index: test.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/test.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- test.xml 5 Jan 2002 15:20:52 -0000 1.5
+++ test.xml 6 Jan 2002 15:39:51 -0000 1.6
@@ -3,7 +3,7 @@
<!--
"Alt (to) RMI" component of the Jakarta Commons Subproject
- $Id: test.xml,v 1.5 2002/01/05 15:20:52 hammant Exp $
+ $Id: test.xml,v 1.6 2002/01/06 15:39:51 hammant Exp $
-->
@@ -92,7 +92,8 @@
<target name="generate" depends="prepare">
<armiinterfaces genname="Hello" gendir="${build.home}/genjava"
- classesorinterfaces="org.apache.commons.armi.test.TestInterface" />
+ classesorinterfaces="org.apache.commons.armi.test.TestInterface"
+ additionalfacades="org.apache.commons.armi.test.TestInterface2"/>
<javac srcdir="${build.home}/genjava"
destdir="${build.home}/classes2"
@@ -102,8 +103,9 @@
<classpath refid="compile.classpath"/>
</javac>
- <armiclassintern genname="Hello" gendir="${build.home}/genjava2"
- encapsulated="${build.home}/classes2/ArmiGeneratedHello.class" />
+ <armiclassintern gendir="${build.home}/genjava2"
+ sourceclassdir="${build.home}/classes2/"
+ sourceclassfilestem="ArmiGeneratedHello" />
<javac srcdir="${build.home}/genjava2"
destdir="${build.home}/classes3"
1.6 +18 -7 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java
Index: ArmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ArmiFactory.java 5 Jan 2002 15:20:52 -0000 1.5
+++ ArmiFactory.java 6 Jan 2002 15:39:51 -0000 1.6
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v 1.5 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.5 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiFactory.java,v 1.6 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -72,7 +72,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public interface ArmiFactory {
@@ -81,7 +81,6 @@
* Method lookup
*
*
- * @param hostContext
* @param publishedServiceName
*
* @return
@@ -89,7 +88,19 @@
* @throws ArmiConnectionException
*
*/
- Object lookup(ArmiHostContext hostContext, String publishedServiceName)
- throws ArmiConnectionException;
+ Object lookup(String publishedServiceName) throws ArmiConnectionException;
+
+ /**
+ * Method setHostContext
+ *
+ *
+ * @param hostContext
+ *
+ * @return
+ *
+ * @throws ArmiConnectionException
+ *
+ */
+ void setHostContext(ArmiHostContext hostContext);
}
1.2 +39 -3 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java
Index: AbstractArmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractArmiFactory.java 5 Jan 2002 15:20:52 -0000 1.1
+++ AbstractArmiFactory.java 6 Jan 2002 15:39:51 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v 1.1 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/AbstractArmiFactory.java,v 1.2 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -62,13 +62,49 @@
package org.apache.commons.armi.client.impl;
import org.apache.commons.armi.client.ArmiFactory;
+import org.apache.commons.armi.client.ArmiHostContext;
+import org.apache.commons.armi.common.ArmiConnectionException;
/**
* Class AbstractArmiFactory
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class AbstractArmiFactory implements ArmiFactory {
+
+ protected ArmiHostContext mHostContext;
+
+ /**
+ * Method setHostContext
+ *
+ *
+ * @param hostContext
+ *
+ * @return
+ *
+ * @throws ArmiConnectionException
+ *
+ */
+ public void setHostContext(ArmiHostContext hostContext) {
+ if (mHostContext == null) {
+ mHostContext = hostContext;
+ }
+ }
+
+ /**
+ * Method getInstance
+ *
+ *
+ * @param publishedServiceName
+ * @param String objectName
+ * @param BaseServedObject baseServedObject
+ *
+ * @return
+ *
+ * @throws ArmiConnectionException
+ *
+ */
+ protected abstract Object getInstance(String publishedServiceName, String objectName, BaseServedObject baseServedObject) throws ArmiConnectionException;
}
1.4 +72 -54 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java
Index: BaseServedObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseServedObject.java 4 Jan 2002 13:15:30 -0000 1.3
+++ BaseServedObject.java 6 Jan 2002 15:39:51 -0000 1.4
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.3 2002/01/04 13:15:30 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/04 13:15:30 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.4 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -70,6 +70,8 @@
import org.apache.commons.armi.common.MethodRequest;
import org.apache.commons.armi.common.ExceptionReply;
import org.apache.commons.armi.common.ArmiInvocationException;
+import org.apache.commons.armi.common.MethodFacadeReply;
+import org.apache.commons.armi.common.MethodFacadeRequest;
/**
@@ -77,39 +79,56 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
-public abstract class BaseServedObject {
+public final class BaseServedObject {
- private ArmiInvocationHandler mInvocationHandler;
- private String mPublishedObjectName;
- private Integer syncObject = new Integer(1);
+ private final AbstractArmiFactory mArmiFactory;
+ private final ArmiInvocationHandler mInvocationHandler;
+ private final String mPublishedServiceName;
+ private final String mObjectName;
+ private final String mReferenceID;
+
+ public BaseServedObject(AbstractArmiFactory armiFactory, ArmiInvocationHandler invocationHandler, String pubishedServiceName, String objectName, String referenceID) {
+ mArmiFactory = armiFactory;
+ mInvocationHandler = invocationHandler;
+ mPublishedServiceName = pubishedServiceName;
+ mObjectName = objectName;
+ mReferenceID = referenceID;
+ }
/**
- * Method armiSetInvocationHandler
- *
+ * Method armiProcessObjectRequest
*
- * @param invocationHandler
*
- */
- public void armiSetInvocationHandler(ArmiInvocationHandler invocationHandler) {
-
- if (mInvocationHandler == null) {
- mInvocationHandler = invocationHandler;
- }
- }
-
- /**
- * Method armiSetPublishedObjectName
+ * @param methodSignature
+ * @param args
*
+ * @return
*
- * @param publishedObjectName
+ * @throws Throwable
*
*/
- public void armiSetPublishedObjectName(String publishedObjectName) {
+ public Object armiProcessObjectRequestGettingFacade(String methodSignature, Object[] args, String objectName)
+ throws Throwable {
+
+ MethodFacadeRequest request = new MethodFacadeRequest(mPublishedServiceName, mObjectName, methodSignature, args, mReferenceID, objectName);
- if (mPublishedObjectName == null) {
- mPublishedObjectName = publishedObjectName;
+ ArmiReply reply = mInvocationHandler.handleInvocation(request);
+
+ if (reply.getReplyCode() == ArmiReply.METHODFACADEREPLY) {
+ MethodFacadeReply mfr = (MethodFacadeReply) reply;
+
+ BaseServedObject bo2 = new BaseServedObject(mArmiFactory, mInvocationHandler, mPublishedServiceName, objectName, mfr.getReferenceID());
+ Object retFacade = mArmiFactory.getInstance(mPublishedServiceName, objectName ,bo2);
+
+ return retFacade;
+ } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
+ ExceptionReply er = (ExceptionReply) reply;
+ throw er.getReplyException();
+ } else {
+ throw new ArmiInvocationException("Internal Error : Unknown reply type :"
+ + reply.getClass().getName());
}
}
@@ -128,21 +147,20 @@
public Object armiProcessObjectRequest(String methodSignature, Object[] args)
throws Throwable {
- MethodRequest request = new MethodRequest(mPublishedObjectName, methodSignature, args);
- synchronized (syncObject) {
- ArmiReply reply = mInvocationHandler.handleInvocation(request);
+ MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName, methodSignature, args, mReferenceID);
+
+ ArmiReply reply = mInvocationHandler.handleInvocation(request);
- if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
- MethodReply or = (MethodReply) reply;
- return or.getReplyObject();
- } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
- ExceptionReply er = (ExceptionReply) reply;
- throw er.getReplyException();
- } else {
- throw new ArmiInvocationException("Internal Error : Unknown reply type :"
- + reply.getClass().getName());
- }
+ if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
+ MethodReply or = (MethodReply) reply;
+ return or.getReplyObject();
+ } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
+ ExceptionReply er = (ExceptionReply) reply;
+ throw er.getReplyException();
+ } else {
+ throw new ArmiInvocationException("Internal Error : Unknown reply type :"
+ + reply.getClass().getName());
}
}
@@ -158,22 +176,22 @@
*/
public void armiProcessVoidRequest(String methodSignature, Object[] args) throws Throwable {
- MethodRequest request = new MethodRequest(mPublishedObjectName, methodSignature, args);
- synchronized (syncObject) {
- ArmiReply reply = mInvocationHandler.handleInvocation(request);
-
- if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
- MethodReply or = (MethodReply) reply;
-
- return;
- } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
- ExceptionReply er = (ExceptionReply) reply;
-
- throw er.getReplyException();
- } else {
- throw new ArmiInvocationException("Internal Error : Unknown reply type :"
- + reply.getClass().getName());
- }
+ MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName, methodSignature, args, mReferenceID);
+
+ ArmiReply reply = mInvocationHandler.handleInvocation(request);
+
+ if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
+ MethodReply or = (MethodReply) reply;
+
+ return;
+ } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
+ ExceptionReply er = (ExceptionReply) reply;
+
+ throw er.getReplyException();
+ } else {
+ throw new ArmiInvocationException("Internal Error : Unknown reply type :"
+ + reply.getClass().getName());
}
+
}
}
1.3 +45 -13 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java
Index: ClientClassArmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClientClassArmiFactory.java 5 Jan 2002 15:20:52 -0000 1.2
+++ ClientClassArmiFactory.java 6 Jan 2002 15:39:51 -0000 1.3
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java,v 1.2 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.2 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ClientClassArmiFactory.java,v 1.3 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -64,13 +64,20 @@
import org.apache.commons.armi.client.ArmiFactory;
import org.apache.commons.armi.client.ArmiHostContext;
import org.apache.commons.armi.common.ArmiConnectionException;
+import org.apache.commons.armi.common.LookupReply;
+import org.apache.commons.armi.common.LookupRequest;
+import org.apache.commons.armi.common.ArmiReply;
+import org.apache.commons.armi.common.NotPublishedReply;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
/**
* Class ClientClassArmiFactory
*
*
* @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 ClientClassArmiFactory extends AbstractArmiFactory {
@@ -78,7 +85,6 @@
* Method lookup
*
*
- * @param hostContext
* @param publishedServiceName
*
* @return
@@ -86,17 +92,43 @@
* @throws ArmiConnectionException
*
*/
- public Object lookup(ArmiHostContext hostContext, String publishedServiceName)
+ public Object lookup(String publishedServiceName)
throws ArmiConnectionException {
+ ArmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new LookupRequest(publishedServiceName));
+ if (ar.getReplyCode() >= ArmiReply.PROBLEMREPLY) {
+ if (ar instanceof NotPublishedReply) {
+ throw new ArmiConnectionException("Service " + publishedServiceName + " not published");
+ } else {
+ throw new ArmiConnectionException("Problem doing lookup on service");
+ }
+ }
+ LookupReply lr = (LookupReply) ar;
+ BaseServedObject bo = new BaseServedObject(this, mHostContext.getInvocationHandler(), publishedServiceName, "Main", lr.getReferenceID());
+ Object retVal = getInstance(publishedServiceName, "Main", bo);
+ return retVal;
+ }
+ /**
+ * Method getInstance
+ *
+ *
+ * @param publishedServiceName
+ * @param objectName
+ *
+ * @return
+ *
+ * @throws ArmiConnectionException
+ *
+ */
+ protected Object getInstance(String publishedServiceName, String objectName, BaseServedObject baseServedObject) throws ArmiConnectionException {
try {
- Class clazz = Class.forName("ArmiGenerated" + publishedServiceName);
- BaseServedObject bo = (BaseServedObject) clazz.newInstance();
-
- bo.armiSetInvocationHandler(hostContext.getInvocationHandler());
- bo.armiSetPublishedObjectName(publishedServiceName);
-
- return bo;
+ Class clazz = Class.forName("ArmiGenerated" + publishedServiceName + "_" +objectName);
+ Constructor[] constructors = clazz.getConstructors();
+ Object retVal = constructors[0].newInstance(new Object[] { baseServedObject });
+ return retVal;
+ } catch (InvocationTargetException ite) {
+ throw new ArmiConnectionException("Generated class not instantiated : "
+ + ite.getTargetException().getMessage());
} catch (ClassNotFoundException cnfe) {
throw new ArmiConnectionException("Generated class not found during lookup : "
+ cnfe.getMessage());
1.8 +11 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java
Index: ObjectStreamInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ObjectStreamInvocationHandler.java 4 Jan 2002 09:35:31 -0000 1.7
+++ ObjectStreamInvocationHandler.java 6 Jan 2002 15:39:51 -0000 1.8
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v 1.7 2002/01/04 09:35:31 hammant Exp $
- * $Revision: 1.7 $
- * $Date: 2002/01/04 09:35:31 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v 1.8 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.8 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -72,6 +72,8 @@
import org.apache.commons.armi.common.NotPublishedReply;
import org.apache.commons.armi.common.NotPublishedException;
import org.apache.commons.armi.common.PublishedNameRequest;
+import org.apache.commons.armi.common.NoSuchReferenceReply;
+import org.apache.commons.armi.common.NotSuchReferenceException;
import org.apache.commons.armi.client.ArmiConnectionListener;
import java.io.IOException;
@@ -85,7 +87,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public abstract class ObjectStreamInvocationHandler extends ArmiClientInvocationHandler {
@@ -138,7 +140,7 @@
* @return
*
*/
- public ArmiReply handleInvocation(ArmiRequest request) {
+ public synchronized ArmiReply handleInvocation(ArmiRequest request) {
try {
while (true) {
@@ -163,8 +165,11 @@
int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
mArmiConnectionListener.serviceSuspended(request,tries,millis);
again = true;
+ } else if (reply instanceof NoSuchReferenceReply) {
+ throw new NotSuchReferenceException();
} else if (reply instanceof NotPublishedReply) {
- throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
+ PublishedNameRequest pnr = (PublishedNameRequest) request;
+ throw new NotPublishedException(pnr.getPublishedServiceName(),pnr.getObjectName());
}
}
} catch (IOException ioe) {
1.5 +61 -15 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java
Index: ServerClassArmiFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerClassArmiFactory.java 5 Jan 2002 15:20:52 -0000 1.4
+++ ServerClassArmiFactory.java 6 Jan 2002 15:39:51 -0000 1.5
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java,v 1.4 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.4 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ServerClassArmiFactory.java,v 1.5 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -68,8 +68,15 @@
import org.apache.commons.armi.common.ArmiConnectionException;
import org.apache.commons.armi.common.ClassRequest;
import org.apache.commons.armi.common.NotPublishedException;
+import org.apache.commons.armi.common.LookupReply;
+import org.apache.commons.armi.common.LookupRequest;
+import org.apache.commons.armi.common.ArmiReply;
+import org.apache.commons.armi.common.NotPublishedReply;
+import org.apache.commons.armi.common.RequestFailedReply;
import java.util.HashMap;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
/**
@@ -77,7 +84,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 ServerClassArmiFactory extends AbstractArmiFactory {
@@ -87,7 +94,6 @@
* Method lookup
*
*
- * @param hostContext
* @param publishedServiceName
*
* @return
@@ -95,27 +101,67 @@
* @throws ArmiConnectionException
*
*/
- public Object lookup(ArmiHostContext hostContext, String publishedServiceName)
+ public Object lookup(String publishedServiceName)
throws ArmiConnectionException {
+
+ ArmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new LookupRequest(publishedServiceName));
+ if (ar.getReplyCode() >= ArmiReply.PROBLEMREPLY) {
+ if (ar instanceof NotPublishedReply) {
+ throw new ArmiConnectionException("Service " + publishedServiceName + " not published");
+ } else {
+ throw new ArmiConnectionException("Problem doing lookup on service");
+ }
+ }
+ LookupReply lr = (LookupReply) ar;
+ BaseServedObject bo = new BaseServedObject(this, mHostContext.getInvocationHandler(), publishedServiceName, "Main", lr.getReferenceID());
+ Object retVal = getInstance(publishedServiceName, "Main", bo);
+ return retVal;
+ }
+
+ /**
+ * Method getInstance
+ *
+ *
+ * @param publishedServiceName
+ * @param objectName
+ *
+ * @return
+ *
+ * @throws ArmiConnectionException
+ *
+ */
+ protected Object getInstance(String publishedServiceName, String objectName, BaseServedObject baseServedObject) throws ArmiConnectionException {
try {
TransportedClassLoader tcl = null;
- if (mPublishedServiceClassLoaders.containsKey(publishedServiceName)) {
- tcl = (TransportedClassLoader) mPublishedServiceClassLoaders.get(publishedServiceName);
+
+ String className = "ArmiGenerated" + publishedServiceName + "_" + objectName;
+
+ if (mPublishedServiceClassLoaders.containsKey(className)) {
+ tcl = (TransportedClassLoader) mPublishedServiceClassLoaders.get(className);
} else {
ClassReply cr = null;
try {
- cr = (ClassReply) hostContext.getInvocationHandler().handleInvocation(new ClassRequest(publishedServiceName));
+ ArmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new ClassRequest(publishedServiceName, objectName));
+ if (ar.getReplyCode() >= ArmiReply.PROBLEMREPLY) {
+ if (ar instanceof RequestFailedReply) {
+ throw new ArmiConnectionException(((RequestFailedReply) ar).getFailureReason());
+ } //TODO others.
+ }
+ cr = (ClassReply) ar;
} catch (NotPublishedException npe) {
throw new ArmiConnectionException("Service " + publishedServiceName + " not published on Server");
}
- tcl = new TransportedClassLoader("ArmiGenerated" + publishedServiceName, cr.getClassBytes());
+ tcl = new TransportedClassLoader(className, cr.getClassBytes());
tcl.initialize();
- mPublishedServiceClassLoaders.put(publishedServiceName, tcl);
+ mPublishedServiceClassLoaders.put(className, tcl);
}
- BaseServedObject bo = (BaseServedObject) tcl.loadClass("ArmiGenerated" + publishedServiceName).newInstance();
- bo.armiSetInvocationHandler(hostContext.getInvocationHandler());
- bo.armiSetPublishedObjectName(publishedServiceName);
- return bo;
+ Class clazz = tcl.loadClass(className);
+ Constructor[] constructors = clazz.getConstructors();
+ Object retVal = constructors[0].newInstance(new Object[] { baseServedObject });
+ return retVal;
+ } catch (InvocationTargetException ite) {
+ throw new ArmiConnectionException("Generated class not instantiated : "
+ + ite.getTargetException().getMessage());
} catch (ClassNotFoundException cnfe) {
throw new ArmiConnectionException("Generated class not found during lookup : "
+ cnfe.getMessage());
1.2 +4 -2 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java
Index: TransportedClassLoader.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportedClassLoader.java 30 Dec 2001 00:42:10 -0000 1.1
+++ TransportedClassLoader.java 6 Jan 2002 15:39:51 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/30 00:42:10 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/TransportedClassLoader.java,v 1.2 2002/01/06 15:39:51 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:51 $
*
* ====================================================================
*
@@ -60,6 +60,8 @@
*
*/
package org.apache.commons.armi.client.impl;
+
+import java.util.HashMap;
public final class TransportedClassLoader extends ClassLoader {
1.3 +6 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectArmiHostContext.java
Index: DirectArmiHostContext.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectArmiHostContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DirectArmiHostContext.java 1 Jan 2002 23:12:47 -0000 1.2
+++ DirectArmiHostContext.java 6 Jan 2002 15:39:52 -0000 1.3
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectArmiHostContext.java,v 1.2 2002/01/01 23:12:47 hammant Exp $
- * $Revision: 1.2 $
- * $Date: 2002/01/01 23:12:47 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectArmiHostContext.java,v 1.3 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -74,7 +74,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 DirectArmiHostContext extends AbstractArmiHostContext {
@@ -92,7 +92,7 @@
super(new DirectInvocationHandler(armiInvocationHandler));
}
- public void setArmiConnectionListener(ArmiConnectionListener armiConnectionListener) {
- }
+ //public void setArmiConnectionListener(ArmiConnectionListener armiConnectionListener) {
+ //}
}
1.8 +10 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java
Index: DirectInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DirectInvocationHandler.java 4 Jan 2002 09:35:31 -0000 1.7
+++ DirectInvocationHandler.java 6 Jan 2002 15:39:52 -0000 1.8
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v 1.7 2002/01/04 09:35:31 hammant Exp $
- * $Revision: 1.7 $
- * $Date: 2002/01/04 09:35:31 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v 1.8 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.8 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -73,6 +73,8 @@
import org.apache.commons.armi.common.PublishedNameRequest;
import org.apache.commons.armi.common.ArmiInvocationException;
import org.apache.commons.armi.common.MethodRequest;
+import org.apache.commons.armi.common.NoSuchReferenceReply;
+import org.apache.commons.armi.common.NotSuchReferenceException;
import org.apache.commons.armi.client.impl.ArmiClientInvocationHandler;
import org.apache.commons.armi.client.ArmiConnectionListener;
@@ -82,7 +84,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
public final class DirectInvocationHandler extends ArmiClientInvocationHandler {
@@ -142,8 +144,11 @@
int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
mArmiConnectionListener.serviceSuspended(request,tries,millis);
again = true;
+ } else if (reply instanceof NoSuchReferenceReply) {
+ throw new NotSuchReferenceException();
} else if (reply instanceof NotPublishedReply) {
- throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
+ PublishedNameRequest pnr = (PublishedNameRequest) request;
+ throw new NotPublishedException(pnr.getPublishedServiceName(),pnr.getObjectName());
}
}
}
1.7 +11 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java
Index: RmiInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RmiInvocationHandler.java 3 Jan 2002 10:49:37 -0000 1.6
+++ RmiInvocationHandler.java 6 Jan 2002 15:39:52 -0000 1.7
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v 1.6 2002/01/03 10:49:37 hammant Exp $
- * $Revision: 1.6 $
- * $Date: 2002/01/03 10:49:37 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v 1.7 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.7 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -73,6 +73,8 @@
import org.apache.commons.armi.common.PublishedNameRequest;
import org.apache.commons.armi.common.ArmiInvocationException;
import org.apache.commons.armi.common.MethodRequest;
+import org.apache.commons.armi.common.NoSuchReferenceReply;
+import org.apache.commons.armi.common.NotSuchReferenceException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
@@ -87,7 +89,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 RmiInvocationHandler extends ArmiClientInvocationHandler {
@@ -159,7 +161,7 @@
* @return
*
*/
- public ArmiReply handleInvocation(ArmiRequest request) {
+ public synchronized ArmiReply handleInvocation(ArmiRequest request) {
boolean again = true;
ArmiReply reply = null;
@@ -179,8 +181,11 @@
int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
mArmiConnectionListener.serviceSuspended(request,tries,millis);
again = true;
+ } else if (reply instanceof NoSuchReferenceReply) {
+ throw new NotSuchReferenceException();
} else if (reply instanceof NotPublishedReply) {
- throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
+ PublishedNameRequest pnr = (PublishedNameRequest) request;
+ throw new NotPublishedException(pnr.getPublishedServiceName(),pnr.getObjectName());
}
}
} catch (RemoteException re) {
1.4 +4 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java
Index: PlainSocketInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PlainSocketInvocationHandler.java 3 Jan 2002 10:49:37 -0000 1.3
+++ PlainSocketInvocationHandler.java 6 Jan 2002 15:39:52 -0000 1.4
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v 1.3 2002/01/03 10:49:37 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/03 10:49:37 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v 1.4 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -75,7 +75,7 @@
*
*
* @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 PlainSocketInvocationHandler extends ObjectStreamInvocationHandler {
@@ -115,7 +115,6 @@
* @return connected or not.
*/
protected boolean tryReconnect() {
- System.out.println("Tryin....");
try {
Socket socket = new Socket(mHost, mPort);
ObjectOutputStream oOS = new ObjectOutputStream(socket.getOutputStream());
1.2 +17 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/AbstractMethodHandler.java
Index: AbstractMethodHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/AbstractMethodHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractMethodHandler.java 28 Dec 2001 18:08:38 -0000 1.1
+++ AbstractMethodHandler.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/AbstractMethodHandler.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/28 18:08:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/AbstractMethodHandler.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -73,7 +73,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 AbstractMethodHandler {
@@ -97,4 +97,17 @@
return methodSignature.toString().intern();
}
+
+ protected String encodeClassName(String className) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < className.length(); i++) {
+ char ch = className.charAt(i);
+ if (Character.isLetter(ch) | Character.isDigit(ch)) {
+ sb.append(ch);
+ }
+ }
+ return sb.toString();
+ }
+
+
}
1.3 +11 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java
Index: ArmiReply.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ArmiReply.java 3 Jan 2002 10:49:37 -0000 1.2
+++ ArmiReply.java 6 Jan 2002 15:39:52 -0000 1.3
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
- * $Revision: 1.2 $
- * $Date: 2002/01/03 10:49:37 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v 1.3 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -71,19 +71,26 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public abstract class ArmiReply implements Serializable {
+ // 'good' replies after 100
+
public static final int CLASSREPLY = 1;
public static final int METHODREPLY = 2;
public static final int EXCEPTIONREPLY = 3;
+ public static final int LOOKUPREPLY = 4;
+ public static final int METHODFACADEREPLY = 5;
+
+ // 'bad' replies after 100
public static final int PROBLEMREPLY = 100;
public static final int NOTPUBLISHEDREPLY = 102;
public static final int REQUESTFAILEDREPLY = 103;
public static final int SUSPENDEDREPLY = 104;
public static final int ENDCONNECTIONREPLY = 105;
+ public static final int NOSUCHREFERENCEREPLY = 106;
1.2 +19 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiRequest.java
Index: ArmiRequest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArmiRequest.java 28 Dec 2001 18:08:38 -0000 1.1
+++ ArmiRequest.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiRequest.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/28 18:08:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiRequest.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -71,14 +71,29 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class ArmiRequest implements Serializable {
+ public static final int CLASSREQUEST = 301;
+ public static final int METHODREQUEST = 302;
+ public static final int METHODFACADEREQUEST = 303;
+ public static final int LOOKUPREQUEST = 304;
+
/**
* Constructor ArmiRequest
*
*
*/
ArmiRequest() {}
+
+ /**
+ * Method getRequestCode. This is quicker than instanceof for type checking.
+ *
+ *
+ * @return
+ *
+ */
+ public abstract int getRequestCode();
+
}
1.3 +19 -7 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java
Index: ClassRequest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ClassRequest.java 31 Dec 2001 13:48:21 -0000 1.2
+++ ClassRequest.java 6 Jan 2002 15:39:52 -0000 1.3
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java,v 1.2 2001/12/31 13:48:21 hammant Exp $
- * $Revision: 1.2 $
- * $Date: 2001/12/31 13:48:21 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassRequest.java,v 1.3 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -67,7 +67,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 ClassRequest extends PublishedNameRequest {
@@ -75,11 +75,23 @@
* Constructor ClassRequest
*
*
- * @param publishedObjectName
+ * @param publishedServiceName
+ * @param objectName*
*
*/
- public ClassRequest(String publishedObjectName) {
- super(publishedObjectName);
+ public ClassRequest(String publishedServiceName, String objectName) {
+ super(publishedServiceName, objectName);
+ }
+
+ /**
+ * Method getRequestCode. This is quicker than instanceof for type checking.
+ *
+ *
+ * @return
+ *
+ */
+ public int getRequestCode() {
+ return CLASSREQUEST;
}
}
1.3 +33 -7 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodRequest.java
Index: MethodRequest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodRequest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MethodRequest.java 31 Dec 2001 13:48:21 -0000 1.2
+++ MethodRequest.java 6 Jan 2002 15:39:52 -0000 1.3
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodRequest.java,v 1.2 2001/12/31 13:48:21 hammant Exp $
- * $Revision: 1.2 $
- * $Date: 2001/12/31 13:48:21 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodRequest.java,v 1.3 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -68,26 +68,30 @@
*
*
* @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 MethodRequest extends PublishedNameRequest {
private final String mMethodSignature;
private final Object[] mArgs;
+ private final String mRferenceID;
/**
* Constructor MethodRequest
*
*
- * @param publishedObjectName
+ * @param publishedServiceName
+ * @param objectName
* @param methodSignature
* @param args
+ * @param referenceID
*
*/
- public MethodRequest(String publishedObjectName, String methodSignature, Object[] args) {
- super(publishedObjectName);
+ public MethodRequest(String publishedServiceName, String objectName, String methodSignature, Object[] args, String referenceID) {
+ super(publishedServiceName, objectName);
mMethodSignature = methodSignature;
mArgs = args;
+ mRferenceID = referenceID;
}
/**
@@ -110,6 +114,28 @@
*/
public Object[] getArgs() {
return mArgs;
+ }
+
+ /**
+ * Method getReferenceID
+ *
+ *
+ * @return
+ *
+ */
+ public String getReferenceID() {
+ return mRferenceID;
+ }
+
+ /**
+ * Method getRequestCode. This is quicker than instanceof for type checking.
+ *
+ *
+ * @return
+ *
+ */
+ public int getRequestCode() {
+ return METHODREQUEST;
}
}
1.2 +6 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedException.java
Index: NotPublishedException.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NotPublishedException.java 31 Dec 2001 13:48:21 -0000 1.1
+++ NotPublishedException.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedException.java,v 1.1 2001/12/31 13:48:21 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/31 13:48:21 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedException.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -71,7 +71,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 NotPublishedException extends ArmiInvocationException {
@@ -80,10 +80,11 @@
* Constructor NotPublishedException
*
*
- * @param s
+ * @param publishedServiceName
+ * @param objectName
*
*/
- public NotPublishedException(String service) {
- super("Service " + service + " not published by server");
+ public NotPublishedException(String publishedServiceName, String objectName) {
+ super("Service '" + publishedServiceName + "' object '" + objectName +"' not published by server");
}
}
1.2 +21 -8 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/PublishedNameRequest.java
Index: PublishedNameRequest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/PublishedNameRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PublishedNameRequest.java 31 Dec 2001 13:48:21 -0000 1.1
+++ PublishedNameRequest.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/PublishedNameRequest.java,v 1.1 2001/12/31 13:48:21 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/31 13:48:21 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/PublishedNameRequest.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -67,11 +67,12 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class PublishedNameRequest extends ArmiRequest {
- private final String mPublishedObjectName;
+ private final String mPublishedServiceName;
+ private final String mObjectName;
/**
* Constructor PublishedNameRequest
@@ -80,18 +81,30 @@
* @param publishedObjectName
*
*/
- public PublishedNameRequest(String publishedObjectName) {
- mPublishedObjectName = publishedObjectName;
+ public PublishedNameRequest(String publishedServiceName, String objectName) {
+ mPublishedServiceName = publishedServiceName;
+ mObjectName = objectName;
}
/**
- * Method getPublishedObjectName
+ * Method getPublishedServiceName
*
*
* @return
*
*/
- public String getPublishedObjectName() {
- return mPublishedObjectName;
+ public String getPublishedServiceName() {
+ return mPublishedServiceName;
+ }
+
+ /**
+ * Method getObjectName
+ *
+ *
+ * @return
+ *
+ */
+ public String getObjectName() {
+ return mObjectName;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/LookupReply.java
Index: LookupReply.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/LookupReply.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
/**
* Class LookupReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class LookupReply extends ArmiReply {
private final String mReferenceID;
/**
* Constructor LookupReply
*
*
* @param referenceID
*
*/
public LookupReply(String referenceID) {
this.mReferenceID = referenceID;
}
/**
* Method getReferenceID.
*
*
* @return
*
*/
public String getReferenceID() {
return mReferenceID;
}
/**
* Method getReplyCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getReplyCode() {
return LOOKUPREPLY;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/LookupRequest.java
Index: LookupRequest.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/LookupRequest.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
/**
* Class LookupRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class LookupRequest extends PublishedNameRequest {
/**
* Constructor LookupRequest
*
*
* @param publishedServiceName
*
*/
public LookupRequest(String publishedServiceName) {
super(publishedServiceName, "Main");
}
/**
* Method getRequestCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getRequestCode() {
return LOOKUPREQUEST;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodFacadeReply.java
Index: MethodFacadeReply.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodFacadeReply.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
/**
* Class MethodFacadeReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class MethodFacadeReply extends ArmiReply {
private final String mReferenceID;
/**
* Constructor MethodFacadeReply
*
*
* @param referenceID
*
*/
public MethodFacadeReply(String referenceID) {
this.mReferenceID = referenceID;
}
/**
* Method getReference
*
*
* @return
*
*/
public String getReferenceID() {
return mReferenceID;
}
/**
* Method getReplyCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getReplyCode() {
return METHODFACADEREPLY;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodFacadeRequest.java
Index: MethodFacadeRequest.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodFacadeRequest.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
/**
* Class MethodFacadeRequest
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class MethodFacadeRequest extends MethodRequest {
private String mReturnClassNameEncoded;
/**
* Constructor MethodFacadeRequest
*
*
* @param publishedServiceName
* @param objectName
* @param methodSignature
* @param args
* @param referenceID
* @param returnClassNameEncoded
*
*/
public MethodFacadeRequest(String publishedServiceName, String objectName, String methodSignature, Object[] args, String referenceID, String returnClassNameEncoded) {
super(publishedServiceName, objectName, methodSignature, args, referenceID);
mReturnClassNameEncoded = returnClassNameEncoded;
}
/**
* Method getRequestCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getRequestCode() {
return METHODFACADEREQUEST;
}
/**
* Method getReturnClassNameEncoded.
*
*
* @return
*
*/
public String getReturnClassNameEncoded() {
return mReturnClassNameEncoded;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NoSuchReferenceReply.java
Index: NoSuchReferenceReply.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NoSuchReferenceReply.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
/**
* Class NoSuchReferenceReply
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class NoSuchReferenceReply extends NotPublishedReply {
/**
* Constructor NoSuchReferenceReply
*
*/
public NoSuchReferenceReply() {
}
/**
* Method getReplyCode. This is quicker than instanceof for type checking.
*
*
* @return
*
*/
public int getReplyCode() {
return NOSUCHREFERENCEREPLY;
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotSuchReferenceException.java
Index: NotSuchReferenceException.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotSuchReferenceException.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.common;
import java.io.Serializable;
/**
* Class NotSuchReferenceException
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public class NotSuchReferenceException extends ArmiInvocationException {
/**
* Constructor NotSuchReferenceException
*
*
* @param publishedServiceName
* @param objectName
*
*/
public NotSuchReferenceException() {
super("The Instance on theserver mapped to a referenceID for transport does not exist.");
}
}
1.5 +62 -18 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java
Index: PrimarySourceGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PrimarySourceGenerator.java 5 Jan 2002 15:20:52 -0000 1.4
+++ PrimarySourceGenerator.java 6 Jan 2002 15:39:52 -0000 1.5
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v 1.4 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.4 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/PrimarySourceGenerator.java,v 1.5 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -81,11 +81,12 @@
*
*
* @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 PrimarySourceGenerator extends AbstractMethodHandler {
private String[] mClassesOrInterfacesToExpose;
+ private String[] mAdditionalFacades;
private String mGenDir;
private String mGenName;
private PrintWriter mClassSource;
@@ -102,6 +103,17 @@
}
/**
+ * Method setClassOrInterfacesToExpose
+ *
+ *
+ * @param classesOrInterfacesToExpose
+ *
+ */
+ public void setAdditionalfacades(String[] additionalFacades) {
+ mAdditionalFacades = additionalFacades;
+ }
+
+ /**
* Method setGenDir
*
*
@@ -132,30 +144,46 @@
*/
public void generate(boolean beanOnly) throws SourceGenerationException {
+ // The lookupable service class source.
+ makeSource(beanOnly, "Main", mClassesOrInterfacesToExpose);
+
+ for (int i = 0; i < mAdditionalFacades.length; i++) {
+ String facade = mAdditionalFacades[i];
+ makeSource(beanOnly, encodeClassName(facade), new String[] { facade } );
+ }
+
+ }
+
+
+ public void makeSource(boolean beanOnly, String name, String[] classOrInterfacesToExpose) throws SourceGenerationException {
+
// methdos could be in more than one interface.
Vector methodsDone = new Vector();
try {
mClassSource = new PrintWriter(new FileOutputStream(mGenDir + "\\ArmiGenerated"
- + mGenName + ".java"));
+ + mGenName + "_" + name + ".java"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
mClassSource
- .print("public final class ArmiGenerated" + mGenName
- + " extends org.apache.commons.armi.client.impl.BaseServedObject ");
+ .print("public final class ArmiGenerated" + mGenName + "_" + name);
if (!beanOnly) {
- mClassSource.print("implements ");
- generateInterfaceList();
+ mClassSource.print(" implements ");
+ generateInterfaceList(classOrInterfacesToExpose);
}
mClassSource.println(" { ");
- for (int x = 0; x < mClassesOrInterfacesToExpose.length; x++) {
+ mClassSource.println(" private transient org.apache.commons.armi.client.impl.BaseServedObject mBaseServedObject;");
+ mClassSource.println(" public ArmiGenerated" + mGenName + "_" + name + " (org.apache.commons.armi.client.impl.BaseServedObject baseServedObject) {");
+ mClassSource.println(" mBaseServedObject = baseServedObject;");
+ mClassSource.println(" }");
+ for (int x = 0; x < classOrInterfacesToExpose.length; x++) {
Class clazz = null;
try {
- clazz = Class.forName(mClassesOrInterfacesToExpose[x]);
+ clazz = Class.forName(classOrInterfacesToExpose[x]);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
@@ -207,13 +235,29 @@
mClassSource.println(" try {");
+
if (rClass.equals("void")) {
- mClassSource.println(" armiProcessVoidRequest(\""
+ mClassSource.println(" mBaseServedObject.armiProcessVoidRequest(\""
+ methodSignature.toString() + "\",args);");
} else {
- mClassSource.println(" Object retVal = armiProcessObjectRequest(\""
+
+ boolean isFacadeRetVal = false;
+ for (int p = 0; p < mAdditionalFacades.length; p++) {
+ if (method.getReturnType().getName().equals(mAdditionalFacades[p])) {
+ isFacadeRetVal = true;
+ break;
+ }
+ }
+
+ if (isFacadeRetVal) {
+ mClassSource.println(" Object retVal = mBaseServedObject.armiProcessObjectRequestGettingFacade(\""
+ + methodSignature.toString() + "\",args,\"" + encodeClassName(rClass)+ "\");");
+ mClassSource.println(" return (" + rClass + ") retVal;");
+ } else {
+ mClassSource.println(" Object retVal = mBaseServedObject.armiProcessObjectRequest(\""
+ methodSignature.toString() + "\",args);");
- generateReturnLine(rClass);
+ generateReturnLine(rClass);
+ }
}
mClassSource.println(" } catch (Throwable t) {");
@@ -271,12 +315,12 @@
}
}
- private void generateInterfaceList() {
+ private void generateInterfaceList(String[] classOrInterfacesToExpose) {
- for (int x = 0; x < mClassesOrInterfacesToExpose.length; x++) {
- mClassSource.print(mClassesOrInterfacesToExpose[x]);
+ for (int x = 0; x < classOrInterfacesToExpose.length; x++) {
+ mClassSource.print(classOrInterfacesToExpose[x]);
- if (x + 1 < mClassesOrInterfacesToExpose.length) {
+ if (x + 1 < classOrInterfacesToExpose.length) {
mClassSource.print(", ");
}
}
1.2 +36 -21 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java
Index: SecondarySourceGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SecondarySourceGenerator.java 30 Dec 2001 00:42:10 -0000 1.1
+++ SecondarySourceGenerator.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/30 00:42:10 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/SecondarySourceGenerator.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -75,46 +75,46 @@
*
*
* @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 SecondarySourceGenerator extends AbstractMethodHandler {
- private File mFile;
+ private File mSourceClassDir;
+ private String mSourceClassFileStem;
private String mGenDir;
- private String mGenName;
private PrintWriter mClassSource;
/**
- * Method setEncapsulated
+ * Method setSourceClassDir
*
*
- * @param file
+ * @param sourceClassDir
*
*/
- public void setEncapsulated(File file) {
- mFile = file;
+ public void setSourceClassDir(File sourceClassDir) {
+ mSourceClassDir = sourceClassDir;
}
/**
- * Method setGenDir
+ * Method setSourceClassFileStem
*
*
- * @param genDir
+ * @param sourceClassFileStem
*
*/
- public void setGenDir(String genDir) {
- mGenDir = genDir;
+ public void setSourceClassFileStem(String sourceClassFileStem) {
+ mSourceClassFileStem = sourceClassFileStem;
}
/**
- * Method setGenName
+ * Method setGenDir
*
*
- * @param genName
+ * @param genDir
*
*/
- public void setGenName(String genName) {
- this.mGenName = genName;
+ public void setGenDir(String genDir) {
+ mGenDir = genDir;
}
/**
@@ -123,16 +123,31 @@
*
*/
public void generate() {
+ String[] files = mSourceClassDir.list();
+ for (int i = 0; i < files.length; i++) {
+ File file = new File(mSourceClassDir, files[i]);
+ String filename = file.getName();
+ if (filename.startsWith(mSourceClassFileStem)) {
+ if (filename.endsWith(".class")) {
+ String name = filename.substring(0,filename.length() - 6);
+ makeSource(name, file);
+ }
+ }
+ }
+ }
+
+ public void makeSource(String genName, File sourceFile) {
+
+ System.out.println("genNAme " + genName);
byte[] clazzbytes = null;
try {
- mClassSource = new PrintWriter(new FileOutputStream(mGenDir + "\\ArmiGenerated"
- + mGenName + ".java"));
+ mClassSource = new PrintWriter(new FileOutputStream(mGenDir + File.separator
+ + genName + ".java"));
- FileInputStream fis = new FileInputStream(mFile);
+ FileInputStream fis = new FileInputStream(sourceFile);
int size = fis.available();
- System.out.println("Size=" + size);
clazzbytes = new byte[size];
fis.read(clazzbytes);
fis.close();
@@ -142,7 +157,7 @@
}
mClassSource
- .println("public final class ArmiGenerated" + mGenName
+ .println("public final class " + genName
+ " extends org.apache.commons.armi.server.impl.BaseMobileClass { ");
mClassSource.println(" public byte[] getClassBytes() { ");
mClassSource.println(" return new byte[] { ");
1.2 +18 -18 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java
Index: ArmiClassInternTask.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ArmiClassInternTask.java 30 Dec 2001 00:42:10 -0000 1.1
+++ ArmiClassInternTask.java 6 Jan 2002 15:39:52 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/30 00:42:10 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiClassInternTask.java,v 1.2 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -65,43 +65,43 @@
import org.apache.commons.armi.generator.SecondarySourceGenerator;
import java.io.File;
+import java.io.IOException;
public class ArmiClassInternTask extends Task {
- private File mGeneratedClass;
private String mGenDir;
- private String mGenName;
+ private String mSourceClassDir;
+ private String mSourceClassFileStem;
public ArmiClassInternTask() {
}
- public void setEncapsulated(File generatedClass) {
- mGeneratedClass = generatedClass;
+ public void setSourceclassdir(String sourceClassDir) {
+ mSourceClassDir = sourceClassDir;
}
- public void setGendir(String genDir) {
- mGenDir = genDir;
+ public void setSourceclassfilestem(String sourceClassFileStem) {
+ mSourceClassFileStem = sourceClassFileStem;
}
- public void setGenname(String genName) {
- this.mGenName = genName;
+ public void setGendir(String genDir) {
+ mGenDir = genDir;
}
-
public void execute() throws BuildException {
- if (mGeneratedClass == null) {
- throw new BuildException("Specify at the class that we are interning");
- }
if (mGenDir == null) {
throw new BuildException("Specify the directory to generate Java source in");
}
- if (mGenName == null) {
- throw new BuildException("Specify the name to use for lookup");
+ if (mSourceClassDir == null) {
+ throw new BuildException("Specify the directories of the class 'source' files");
+ }
+ if (mSourceClassFileStem == null) {
+ throw new BuildException("Specify the stem name of class 'source' files");
}
SecondarySourceGenerator sg = new SecondarySourceGenerator();
sg.setGenDir(mGenDir);
- sg.setGenName(mGenName);
- sg.setEncapsulated(mGeneratedClass);
+ sg.setSourceClassDir( new File(mSourceClassDir));
+ sg.setSourceClassFileStem(mSourceClassFileStem);
sg.generate();
}
}
1.4 +16 -6 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java
Index: ArmiInterfaceTask.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ArmiInterfaceTask.java 5 Jan 2002 15:20:52 -0000 1.3
+++ ArmiInterfaceTask.java 6 Jan 2002 15:39:52 -0000 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v 1.3 2002/01/05 15:20:52 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/05 15:20:52 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/generator/ant/ArmiInterfaceTask.java,v 1.4 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -72,6 +72,7 @@
public class ArmiInterfaceTask extends Task {
private String[] mClassOrInterfacesToExpose;
+ private String[] mAdditionalFacades;
private String mGenDir;
private String mGenName;
private boolean mBeanOnly;
@@ -79,16 +80,24 @@
public ArmiInterfaceTask() {
}
- public void setClassesorinterfaces(String ClassOrInterfacesToExpose) {
- StringTokenizer st = new StringTokenizer(ClassOrInterfacesToExpose, ",");
+ public void setClassesorinterfaces(String classOrInterfacesToExpose) {
+ StringTokenizer st = new StringTokenizer(classOrInterfacesToExpose, ",");
Vector strings = new Vector();
while (st.hasMoreTokens()) {
strings.add(st.nextToken().trim());
}
mClassOrInterfacesToExpose = new String[strings.size()];
strings.copyInto(mClassOrInterfacesToExpose);
+ }
-
+ public void setAdditionalfacades(String additionalfacades) {
+ StringTokenizer st = new StringTokenizer(additionalfacades, ",");
+ Vector strings = new Vector();
+ while (st.hasMoreTokens()) {
+ strings.add(st.nextToken().trim());
+ }
+ mAdditionalFacades = new String[strings.size()];
+ strings.copyInto(mAdditionalFacades);
}
public void setGendir(String genDir) {
@@ -118,6 +127,7 @@
sg.setGenDir(mGenDir);
sg.setGenName(mGenName);
sg.setClassOrInterfacesToExpose(mClassOrInterfacesToExpose);
+ sg.setAdditionalfacades(mAdditionalFacades);
try {
sg.generate(mBeanOnly);
} catch (SourceGenerationException sge) {
1.7 +29 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java
Index: ArmiServer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ArmiServer.java 5 Jan 2002 15:20:53 -0000 1.6
+++ ArmiServer.java 6 Jan 2002 15:39:52 -0000 1.7
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v 1.6 2002/01/05 15:20:53 hammant Exp $
- * $Revision: 1.6 $
- * $Date: 2002/01/05 15:20:53 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v 1.7 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.7 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -72,7 +72,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 interface ArmiServer {
@@ -93,10 +93,35 @@
*
* @param impl
* @param asName
+ * @param classOrInterfaceToExpose
+ * @param additionalFacade
+ *
+ */
+ void publish(Object impl, String asName, Class classOrInterfaceToExpose, Class additionalFacade) throws ArmiPublicationException;
+
+ /**
+ * Method publish
+ *
+ *
+ * @param impl
+ * @param asName
* @param classesOrInterfacesToExpose
*
*/
void publish(Object impl, String asName, Class[] classesOrInterfacesToExpose) throws ArmiPublicationException;
+
+ /**
+ * Method publish
+ *
+ *
+ * @param impl
+ * @param asName
+ * @param classesOrInterfacesToExpose
+ * @param additionalFacades
+ *
+ */
+ void publish(Object impl, String asName, Class[] classesOrInterfacesToExpose, Class[] additionalFacades) throws ArmiPublicationException;
+
/**
* Method unPublish
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServerInvocationHandler.java
Index: ArmiServerInvocationHandler.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServerInvocationHandler.java,v 1.1 2002/01/06 15:39:52 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.server;
import org.apache.commons.armi.common.ArmiInvocationHandler;
/**
* Class ArmiServerInvocationHandler
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version $Revision: 1.1 $
*/
public interface ArmiServerInvocationHandler extends ArmiInvocationHandler {
/**
* Method addImplementationBean
*
*
* @param referenceID
* @param beanImpl
*
*/
void addImplementationBean(String referenceID, Object beanImpl);
/**
* Method replaceImplementationBean
*
*
* @param implBean
* @param withImplBean
*
*/
void replaceImplementationBean(Object implBean, Object withImplBean);
/**
* Method getOrMakeReferenceIDForBean
*
*
* @param implBean
*
*/
String getOrMakeReferenceIDForBean(Object implBean);
}
1.10 +115 -24 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java
Index: AbstractServer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractServer.java 5 Jan 2002 15:20:53 -0000 1.9
+++ AbstractServer.java 6 Jan 2002 15:39:52 -0000 1.10
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.9 2002/01/05 15:20:53 hammant Exp $
- * $Revision: 1.9 $
- * $Date: 2002/01/05 15:20:53 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.10 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.10 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -79,8 +79,14 @@
import org.apache.commons.armi.common.TryLaterReply;
import org.apache.commons.armi.common.NotPublishedReply;
import org.apache.commons.armi.common.SuspendedReply;
+import org.apache.commons.armi.common.LookupRequest;
+import org.apache.commons.armi.common.LookupReply;
+import org.apache.commons.armi.common.MethodFacadeRequest;
+import org.apache.commons.armi.common.MethodFacadeReply;
+import org.apache.commons.armi.common.MethodReply;
import org.apache.commons.armi.server.ArmiClassRetrievalException;
import org.apache.commons.armi.server.ClassRetriever;
+import org.apache.commons.armi.server.ArmiServerInvocationHandler;
import java.lang.reflect.Method;
@@ -94,7 +100,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 abstract class AbstractServer extends AbstractMethodHandler implements ArmiServer {
@@ -120,7 +126,21 @@
*
*/
public void publish(Object impl, String asName, Class classOrInterfaceToExpose) throws ArmiPublicationException{
- publish(impl, asName, new Class[]{ classOrInterfaceToExpose });
+ publish(impl, asName, new Class[]{ classOrInterfaceToExpose }, new Class[0]);
+ }
+
+ /**
+ * Method publish
+ *
+ *
+ * @param impl
+ * @param asName
+ * @param classOrInterfaceToExpose
+ * @param additionalFacade
+ *
+ */
+ public void publish(Object impl, String asName, Class classOrInterfaceToExpose, Class additionalFacade) throws ArmiPublicationException {
+ publish(impl, asName, new Class[]{ classOrInterfaceToExpose }, new Class[] { additionalFacade });
}
/**
@@ -133,8 +153,23 @@
*
*/
public void publish(Object impl, String asName, Class[] classesOrInterfacesToExpose) throws ArmiPublicationException{
+ publish(impl, asName, classesOrInterfacesToExpose , new Class[0]);
+ }
- if (mPublishedObjects.containsKey(asName)) {
+ /**
+ * Method publish
+ *
+ *
+ * @param impl
+ * @param asName
+ * @param classesOrInterfacesToExpose
+ * @param additionalFacades
+ *
+ */
+
+ public void publish(Object impl, String asName, Class[] classesOrInterfacesToExpose, Class[] additionalFacades) throws ArmiPublicationException{
+
+ if (mPublishedObjects.containsKey(asName + "_Main")) {
throw new ArmiPublicationException("Service '"+asName+"' already published");
}
@@ -144,8 +179,12 @@
interfaceNames[i] = classesOrInterfacesToExpose[i].getName();
}
- HashMap methodMap = new HashMap();
- DefaultInvocationHandler dih = new DefaultInvocationHandler(impl, methodMap);
+ // add method maps for main lookup-able service.
+
+ HashMap mainMethodMap = new HashMap();
+ ArmiServerInvocationHandler mainAsih = new DefaultInvocationHandler(mainMethodMap);
+ mainAsih.addImplementationBean("<MAIN>", impl);
+
for (int x = 0; x < classesOrInterfacesToExpose.length; x++) {
Method methods[] = classesOrInterfacesToExpose[x].getMethods();
@@ -154,13 +193,37 @@
Method method = methods[y];
String methodSignature = getMethodSignature(method);
+ if (!mainMethodMap.containsKey(methodSignature.toString())) {
+ mainMethodMap.put(methodSignature.toString(), methods[y]);
+ }
+ }
+ }
+
+ // as the main service is lookup-able, it has a prexisting impl.
+
+ mPublishedObjects.put(asName + "_Main", mainAsih);
+
+ // add method maps for all the additional facades.
+
+ for (int x = 0; x < additionalFacades.length; x++) {
+ Method methods[] = additionalFacades[x].getMethods();
+
+ HashMap methodMap = new HashMap();
+ ArmiServerInvocationHandler asih = new DefaultInvocationHandler(methodMap);
+
+ for (int y = 0; y < methods.length; y++) {
+ Method method = methods[y];
+ String methodSignature = getMethodSignature(method);
+
if (!methodMap.containsKey(methodSignature.toString())) {
methodMap.put(methodSignature.toString(), methods[y]);
}
}
+ String encodedClassName = encodeClassName(additionalFacades[x].getName());
+ mPublishedObjects.put(asName + "_" + encodedClassName, asih);
+
}
- mPublishedObjects.put(asName, dih);
}
@@ -174,10 +237,10 @@
*/
public void unPublish(Object impl, String asName) throws ArmiPublicationException {
- if (!mPublishedObjects.containsKey(asName)) {
+ if (!mPublishedObjects.containsKey(asName + "_Main")) {
throw new ArmiPublicationException("Service '"+asName+"' not published");
}
-
+ mPublishedObjects.remove(asName + "_Main");
}
/**
@@ -191,17 +254,13 @@
*/
public void replacePublished(Object oldImpl, String asName, Object withImpl) throws ArmiPublicationException {
- if (!mPublishedObjects.containsKey(asName)) {
+ if (!mPublishedObjects.containsKey(asName + "_Main")) {
throw new ArmiPublicationException("Service '"+asName+"' not published");
}
- DefaultInvocationHandler dih = (DefaultInvocationHandler) mPublishedObjects.get(asName);
+ ArmiServerInvocationHandler asih = (ArmiServerInvocationHandler) mPublishedObjects.get(asName + "_Main");
- if (!dih.isImplementaion(oldImpl)) {
- throw new ArmiPublicationException("Service '"+asName+"' is currently publishing a different implementation to the one you want to replace.");
- }
-
- dih.setImplementationBean(withImpl);
+ asih.replaceImplementationBean(oldImpl, withImpl);
}
@@ -234,19 +293,51 @@
return new SuspendedReply();
}
- if (request instanceof MethodRequest) {
+ if (request.getRequestCode() == ArmiRequest.METHODREQUEST) {
MethodRequest mr = (MethodRequest) request;
- String publishedObjectName = mr.getPublishedObjectName();
- if (!mPublishedObjects.containsKey(publishedObjectName)) {
+ String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
+ if (!mPublishedObjects.containsKey(publishedThing)) {
+ System.out.flush();
return new NotPublishedReply();
}
- ArmiInvocationHandler ih = (ArmiInvocationHandler) mPublishedObjects.get(publishedObjectName);
+ ArmiInvocationHandler ih = (ArmiInvocationHandler) mPublishedObjects.get(publishedThing);
return ih.handleInvocation(mr);
- } else if (request instanceof ClassRequest) {
+ } else if (request.getRequestCode() == ArmiRequest.METHODFACADEREQUEST) {
+ MethodFacadeRequest mr = (MethodFacadeRequest) request;
+ String publishedThing = mr.getPublishedServiceName() + "_" + mr.getObjectName();
+ if (!mPublishedObjects.containsKey(publishedThing)) {
+ System.out.flush();
+ return new NotPublishedReply();
+ }
+
+ ArmiServerInvocationHandler asih = (ArmiServerInvocationHandler) mPublishedObjects.get(publishedThing);
+ ArmiReply ar = asih.handleInvocation(mr);
+ if (ar.getReplyCode() == ArmiReply.EXCEPTIONREPLY ) {
+ return ar;
+ } else if (ar.getReplyCode() >= ArmiReply.PROBLEMREPLY ) {
+ return ar;
+ } else if (ar.getReplyCode() != ArmiReply.METHODREPLY ) {
+ return new RequestFailedReply("TODO");
+ }
+ Object beanImpl = ((MethodReply) ar).getReplyObject();
+ ArmiServerInvocationHandler asih2 = (ArmiServerInvocationHandler) mPublishedObjects.get(mr.getPublishedServiceName() + "_" + mr.getReturnClassNameEncoded());
+ if (asih2 == null) {
+ return new NotPublishedReply();
+ }
+ String newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
+ String newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
+ return new MethodFacadeReply(newRef);
+ } else if (request.getRequestCode() == ArmiRequest.LOOKUPREQUEST) {
+ LookupRequest lr = (LookupRequest) request;
+ //TODO
+ return new LookupReply("<MAIN>");
+ } else if (request.getRequestCode() == ArmiRequest.CLASSREQUEST) {
try {
ClassRequest cr = (ClassRequest) request;
- return new ClassReply(mClassRetriever.getBytes(cr.getPublishedObjectName()));
+ String publishedThing = cr.getPublishedServiceName() + "_" + cr.getObjectName();
+ return new ClassReply(mClassRetriever.getBytes(publishedThing));
} catch (ArmiClassRetrievalException e) {
+
return new RequestFailedReply(e.getMessage());
}
} else {
1.4 +54 -19 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java
Index: DefaultInvocationHandler.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultInvocationHandler.java 3 Jan 2002 10:49:38 -0000 1.3
+++ DefaultInvocationHandler.java 6 Jan 2002 15:39:52 -0000 1.4
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v 1.4 2002/01/06 15:39:52 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:52 $
*
* ====================================================================
*
@@ -70,8 +70,12 @@
import org.apache.commons.armi.common.MethodRequest;
import org.apache.commons.armi.common.ArmiRequest;
import org.apache.commons.armi.common.ArmiInvocationException;
+import org.apache.commons.armi.common.NoSuchReferenceReply;
+import org.apache.commons.armi.server.ArmiServerInvocationHandler;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collection;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
@@ -84,12 +88,14 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
-public class DefaultInvocationHandler implements ArmiInvocationHandler {
+public class DefaultInvocationHandler implements ArmiServerInvocationHandler {
- private Object mImplBean;
+ private HashMap mRefBeans = new HashMap();
+ private HashMap mBeanRefs = new HashMap();
private HashMap mMethodMap;
+ private long mNextReference = 1;
/**
* Constructor DefaultInvocationHandler
@@ -99,37 +105,60 @@
* @param methodMap
*
*/
- protected DefaultInvocationHandler(Object implBean, HashMap methodMap) {
- mImplBean = implBean;
+ protected DefaultInvocationHandler(HashMap methodMap) {
mMethodMap = methodMap;
}
/**
- * Method setImplementationBean
+ * Method addImplementationBean
*
*
- * @param implBean
+ * @param referenceID
+ * @param beanImpl
*
*/
- protected void setImplementationBean(Object implBean) {
- mImplBean = implBean;
+ public void addImplementationBean(String referenceID, Object beanImpl) {
+ mRefBeans.put(referenceID, beanImpl);
+ mBeanRefs.put(beanImpl, referenceID);
}
-
/**
- * Method isImplementaion
+ * Method replaceImplementationBean
*
*
* @param implBean
- *
- * @return if the param matches the bean that is the current impl.
+ * @param withImplBean
*
*/
- protected boolean isImplementaion(Object implBean) {
- return (implBean == mImplBean);
+ public void replaceImplementationBean(Object implBean, Object withImplBean) {
+ Collection coll = mRefBeans.keySet();
+ for (Iterator iterator = coll.iterator(); iterator.hasNext();) {
+ String ref = (String) iterator.next();
+ if (mRefBeans.get(ref).equals(implBean)) {
+ mRefBeans.put(ref, withImplBean);
+ mBeanRefs.remove(implBean);
+ mBeanRefs.put(withImplBean, ref);
+ }
+ }
}
+ /**
+ * Method getOrMakeReferenceIDForBean
+ *
+ *
+ * @param implBean
+ *
+ */
+ public String getOrMakeReferenceIDForBean(Object implBean) {
+ String ref = (String) mBeanRefs.get(implBean);
+ if (ref == null) {
+ ref = (mNextReference++ + "_" + Math.random()).intern(); // guarantees no spoofing.
+ mBeanRefs.put(implBean, ref);
+ mRefBeans.put(ref,implBean);
+ }
+ return ref;
+ }
/**
* Method handleInvocation
@@ -152,7 +181,12 @@
Object rv = null;
try {
- return new MethodReply(method.invoke(mImplBean, mr.getArgs()));
+
+ Object beanImpl = mRefBeans.get(mr.getReferenceID());
+ if (beanImpl == null) {
+ return new NoSuchReferenceReply();
+ }
+ return new MethodReply(method.invoke(beanImpl, mr.getArgs()));
} catch (InvocationTargetException ite) {
Throwable t = ite.getTargetException();
@@ -164,6 +198,7 @@
"Exception was not serializable :" + t.getClass().getName()));
}
} catch (Throwable t) {
+ t.printStackTrace();
return new ExceptionReply(
new ArmiInvocationException(
"Some ServerSide exception problem :" + t.getMessage()));
1.6 +11 -9 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java
Index: DirectTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DirectTest.java 3 Jan 2002 10:49:38 -0000 1.5
+++ DirectTest.java 6 Jan 2002 15:39:53 -0000 1.6
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.5 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.5 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.6 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -79,7 +79,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class DirectTest {
@@ -103,7 +103,7 @@
DirectServer ds = new DirectServer();
TestInterfaceImpl ti = new TestInterfaceImpl();
- ds.publish(ti, "Hello", TestInterface.class);
+ ds.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
ds.start();
DirectTestClient dtc = new DirectTestClient(new DirectArmiInovcationAdapter(ds));
@@ -117,7 +117,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
static class DirectTestClient implements Runnable {
@@ -143,12 +143,14 @@
try {
ArmiHostContext arhc = new DirectArmiHostContext(mInvocationHandler);
- TestInterface ti = null;
+ ArmiFactory af = null;
if (mServerOrClientFactory.equals("S")) {
- ti = (TestInterface) new ServerClassArmiFactory().lookup(arhc, "Hello");
+ af = new ServerClassArmiFactory();
} else {
- ti = (TestInterface) new ClientClassArmiFactory().lookup(arhc, "Hello");
+ af = new ClientClassArmiFactory();
}
+ af.setHostContext(arhc);
+ TestInterface ti = (TestInterface) af.lookup("Hello");
TestClient tc = new TestClient(ti);
} catch (ArmiConnectionException ace) {
System.err.println("Some problem during connection to server : "
1.6 +11 -9 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java
Index: PipeTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PipeTest.java 3 Jan 2002 10:49:38 -0000 1.5
+++ PipeTest.java 6 Jan 2002 15:39:53 -0000 1.6
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.5 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.5 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.6 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -80,7 +80,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class PipeTest {
@@ -104,7 +104,7 @@
PipedServer ps = new PipedServer();
TestInterfaceImpl ti = new TestInterfaceImpl();
- ps.publish(ti, "Hello", TestInterface.class);
+ ps.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
ps.start();
PipedTestClient ptc = new PipedTestClient(ps);
@@ -118,7 +118,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
static class PipedTestClient implements Runnable {
@@ -144,12 +144,14 @@
try {
ArmiHostContext arhc = new PipedArmiHostContext(mPipedServer);
- TestInterface ti = null;
+ ArmiFactory af = null;
if (mServerOrClientFactory.equals("S")) {
- ti = (TestInterface) new ServerClassArmiFactory().lookup(arhc, "Hello");
+ af = new ServerClassArmiFactory();
} else {
- ti = (TestInterface) new ClientClassArmiFactory().lookup(arhc, "Hello");
+ af = new ClientClassArmiFactory();
}
+ af.setHostContext(arhc);
+ TestInterface ti = (TestInterface) af.lookup("Hello");
TestClient tc = new TestClient(ti);
} catch (ArmiConnectionException ace) {
System.err.println("Some problem during connection to server : "
1.5 +9 -7 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java
Index: RmiClientTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RmiClientTest.java 31 Dec 2001 12:07:31 -0000 1.4
+++ RmiClientTest.java 6 Jan 2002 15:39:53 -0000 1.5
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.4 2001/12/31 12:07:31 hammant Exp $
- * $Revision: 1.4 $
- * $Date: 2001/12/31 12:07:31 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiClientTest.java,v 1.5 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -75,7 +75,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 RmiClientTest {
@@ -95,12 +95,14 @@
ArmiHostContext arhc = new RmiArmiHostContext("127.0.0.1", 4321);
- TestInterface ti = null;
+ ArmiFactory af = null;
if (args[0].equals("S")) {
- ti = (TestInterface) new ServerClassArmiFactory().lookup(arhc, "Hello");
+ af = new ServerClassArmiFactory();
} else {
- ti = (TestInterface) new ClientClassArmiFactory().lookup(arhc, "Hello");
+ af = new ClientClassArmiFactory();
}
+ af.setHostContext(arhc);
+ TestInterface ti = (TestInterface) af.lookup("Hello");
new TestClient(ti);
1.4 +5 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java
Index: RmiServerTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RmiServerTest.java 3 Jan 2002 10:49:38 -0000 1.3
+++ RmiServerTest.java 6 Jan 2002 15:39:53 -0000 1.4
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v 1.4 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -73,7 +73,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class RmiServerTest {
@@ -93,7 +93,7 @@
RmiServer rs = new RmiServer("127.0.0.1", 4321);
TestInterfaceImpl ti = new TestInterfaceImpl();
- rs.publish(ti, "Hello", TestInterface.class);
+ rs.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
rs.start();
}
}
1.5 +9 -8 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java
Index: SocketClientTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SocketClientTest.java 31 Dec 2001 12:07:31 -0000 1.4
+++ SocketClientTest.java 6 Jan 2002 15:39:53 -0000 1.5
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.4 2001/12/31 12:07:31 hammant Exp $
- * $Revision: 1.4 $
- * $Date: 2001/12/31 12:07:31 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketClientTest.java,v 1.5 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -78,7 +78,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 SocketClientTest {
@@ -98,13 +98,14 @@
ArmiHostContext arhc = new PlainSocketArmiHostContext("127.0.0.1", 1234);
-
- TestInterface ti = null;
+ ArmiFactory af = null;
if (args[0].equals("S")) {
- ti = (TestInterface) new ServerClassArmiFactory().lookup(arhc, "Hello");
+ af = new ServerClassArmiFactory();
} else {
- ti = (TestInterface) new ClientClassArmiFactory().lookup(arhc, "Hello");
+ af = new ClientClassArmiFactory();
}
+ af.setHostContext(arhc);
+ TestInterface ti = (TestInterface) af.lookup("Hello");
new TestClient(ti);
}
1.4 +5 -5 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java
Index: SocketServerTest.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SocketServerTest.java 3 Jan 2002 10:49:38 -0000 1.3
+++ SocketServerTest.java 6 Jan 2002 15:39:53 -0000 1.4
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.3 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v 1.4 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.4 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -73,7 +73,7 @@
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class SocketServerTest {
@@ -93,7 +93,7 @@
PlainSocketServer pss = new PlainSocketServer(1234);
TestInterfaceImpl ti = new TestInterfaceImpl();
- pss.publish(ti, "Hello", TestInterface.class);
+ pss.publish(ti, "Hello", TestInterface.class, TestInterface2.class);
pss.start();
}
}
1.5 +18 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestClient.java 3 Jan 2002 10:49:38 -0000 1.4
+++ TestClient.java 6 Jan 2002 15:39:53 -0000 1.5
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.4 2002/01/03 10:49:38 hammant Exp $
- * $Revision: 1.4 $
- * $Date: 2002/01/03 10:49:38 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.5 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -77,7 +77,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 {
@@ -109,6 +109,20 @@
}
System.out.println("CLT: " + ti.hello4((float) 1.3, 2.1));
+
+ System.out.println("CLT: Other Facade tests");
+
+ TestInterface2 ti2One = ti.makeSecondThing("One");
+ TestInterface2 ti2Two = ti.makeSecondThing("Two");
+
+ System.out.println("CLT: One name = '" + ti2One.getName() + "'");
+ System.out.println("CLT: Two name = '" + ti2Two.getName() + "'");
+
+ System.out.println("CLT: Changing name for One to '111'");
+ ti2One.setName("111");
+
+ System.out.println("CLT: One name = '" + ti2One.getName() + "'");
+ System.out.println("CLT: Two name = '" + ti2Two.getName() + "'");
System.out.println("CLT: Two timings about to start, please stand by...");
1.2 +7 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java
Index: TestInterface.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestInterface.java 28 Dec 2001 18:08:39 -0000 1.1
+++ TestInterface.java 6 Jan 2002 15:39:53 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/28 18:08:39 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface.java,v 1.2 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -73,7 +73,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 interface TestInterface {
@@ -122,5 +122,8 @@
StringBuffer hello4(float greeting1, double greeting2);
void testSpeed();
+
String testSpeed2(String string);
+
+ TestInterface2 makeSecondThing(String thingName);
}
1.2 +8 -4 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java
Index: TestInterfaceImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestInterfaceImpl.java 28 Dec 2001 18:08:39 -0000 1.1
+++ TestInterfaceImpl.java 6 Jan 2002 15:39:53 -0000 1.2
@@ -1,8 +1,8 @@
/*
- * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
- * $Revision: 1.1 $
- * $Date: 2001/12/28 18:08:39 $
+ * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterfaceImpl.java,v 1.2 2002/01/06 15:39:53 hammant Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
@@ -73,7 +73,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 TestInterfaceImpl implements TestInterface {
@@ -150,5 +150,9 @@
public String testSpeed2(String string) {
return "abc123";
+ }
+
+ public TestInterface2 makeSecondThing(String thingName) {
+ return new TestInterface2Impl(thingName);
}
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java
Index: TestInterface2.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2.java,v 1.1 2002/01/06 15:39:53 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.test;
import java.beans.PropertyVetoException;
import java.io.IOException;
/**
* Interface TestInterface
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version * $Revision: 1.1 $
*/
public interface TestInterface2 {
/**
* Method setName
*
*
* @param newThingName
*
*/
void setName(String newThingName);
/**
* Method getName
*
*
*
* @return
*
*/
String getName();
}
1.1 jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java
Index: TestInterface2Impl.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestInterface2Impl.java,v 1.1 2002/01/06 15:39:53 hammant Exp $
* $Revision: 1.1 $
* $Date: 2002/01/06 15:39:53 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.armi.test;
/**
* Class TestInterface2Impl
*
*
* @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
* @version * $Revision: 1.1 $
*/
public class TestInterface2Impl implements TestInterface2 {
private String mName;
public TestInterface2Impl(String name) {
System.out.println("SVR: Object " + this + " created with name: '" + name + "'");
mName = name;
}
/**
* Method setName
*
*
* @param newThingName
*
*/
public void setName(String newThingName) {
mName = newThingName;
System.out.println("SVR: Object " + this + " name changed to: '" + newThingName + "'");
}
/**
* Method getName
*
*
*
* @return
*
*/
public String getName() {
return mName;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>