hammant 02/01/12 16:13:53
Modified: altrmi altrmi-tests.xml
altrmi/src/java/org/apache/commons/altrmi/client
AltrmiInterfaceLookup.java
altrmi/src/java/org/apache/commons/altrmi/client/impl
AbstractAltrmiFactory.java BaseServedObject.java
ClientClassAltrmiFactory.java
ServerClassAltrmiFactory.java
TransportedClassLoader.java
altrmi/src/java/org/apache/commons/altrmi/common
ClassReply.java
altrmi/src/java/org/apache/commons/altrmi/generator
PrimarySourceGenerator.java
SecondarySourceGenerator.java
altrmi/src/java/org/apache/commons/altrmi/generator/ant
AltrmiClassInternTask.java AltrmiInterfaceTask.java
altrmi/src/java/org/apache/commons/altrmi/server
ClassRetriever.java
altrmi/src/java/org/apache/commons/altrmi/server/impl
AbstractServer.java BaseMobileClassRetriever.java
JarFileClassRetriever.java NoClassRetriever.java
Added: altrmi/src/java/org/apache/commons/altrmi/server/impl
AbstractClassRetriever.java
Log:
rework to aid interfaceless method invocation
Revision Changes Path
1.2 +2 -2 jakarta-commons-sandbox/altrmi/altrmi-tests.xml
Index: altrmi-tests.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/altrmi-tests.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- altrmi-tests.xml 9 Jan 2002 19:25:53 -0000 1.1
+++ altrmi-tests.xml 13 Jan 2002 00:13:52 -0000 1.2
@@ -3,7 +3,7 @@
<!--
"Alt (to) RMI" component of the Jakarta Commons Subproject
- $Id: altrmi-tests.xml,v 1.1 2002/01/09 19:25:53 hammant Exp $
+ $Id: altrmi-tests.xml,v 1.2 2002/01/13 00:13:52 hammant Exp $
-->
@@ -105,7 +105,7 @@
<altrmiclassintern gendir="${build.home}/genjava2"
sourceclassdir="${build.home}/classes2/"
- sourceclassfilestem="AltrmiGeneratedHello" />
+ publishedname="Hello" />
<javac srcdir="${build.home}/genjava2"
destdir="${build.home}/classes3"
1.2 +16 -3
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/AltrmiInterfaceLookup.java
Index: AltrmiInterfaceLookup.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/AltrmiInterfaceLookup.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AltrmiInterfaceLookup.java 9 Jan 2002 21:08:37 -0000 1.1
+++ AltrmiInterfaceLookup.java 13 Jan 2002 00:13:52 -0000 1.2
@@ -1,10 +1,12 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
- */package org.apache.commons.altrmi.client;
+ */
+package org.apache.commons.altrmi.client;
@@ -17,11 +19,10 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public interface AltrmiInterfaceLookup {
-
/**
* Method lookup
*
@@ -35,5 +36,17 @@
*/
Object lookup(String publishedServiceName) throws AltrmiConnectionException;
-
+ /**
+ * Method lookupBeanOnly
+ *
+ *
+ * @param publishedServiceName
+ * @param beanOnly
+ *
+ * @return
+ *
+ * @throws AltrmiConnectionException
+ *
+ */
+ Object lookup(String publishedServiceName, boolean beanOnly) throws
AltrmiConnectionException;
}
1.2 +17 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java
Index: AbstractAltrmiFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractAltrmiFactory.java 9 Jan 2002 19:25:53 -0000 1.1
+++ AbstractAltrmiFactory.java 13 Jan 2002 00:13:52 -0000 1.2
@@ -18,7 +18,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class AbstractAltrmiFactory implements AltrmiFactory {
@@ -57,7 +57,22 @@
* @throws AltrmiConnectionException
*
*/
- protected abstract Object getInstance(String publishedServiceName, String
objectName, BaseServedObject baseServedObject) throws AltrmiConnectionException;
+ protected abstract Object getInstance(String publishedServiceName, String
objectName, BaseServedObject baseServedObject, boolean beanOnly) throws
AltrmiConnectionException;
+
+ /**
+ * Method lookup
+ *
+ *
+ * @param publishedServiceName
+ *
+ * @return
+ *
+ * @throws AltrmiConnectionException
+ *
+ */
+ public final Object lookup(String publishedServiceName) throws
AltrmiConnectionException {
+ return lookup(publishedServiceName, false);
+ }
/**
* Method registerReferenceObject
1.2 +58 -20
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java
Index: BaseServedObject.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseServedObject.java 9 Jan 2002 19:25:53 -0000 1.1
+++ BaseServedObject.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -27,7 +27,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public final class BaseServedObject {
@@ -36,8 +36,26 @@
private final String mPublishedServiceName;
private final String mObjectName;
private final String mReferenceID;
+ private final boolean mBeanOnly;
- public BaseServedObject(AbstractAltrmiFactory altrmiFactory,
AltrmiInvocationHandler invocationHandler, String pubishedServiceName, String
objectName, String referenceID) {
+ /**
+ * Constructor BaseServedObject
+ *
+ *
+ * @param altrmiFactory
+ * @param invocationHandler
+ * @param pubishedServiceName
+ * @param objectName
+ * @param referenceID
+ * @param beanOnly
+ *
+ */
+ public BaseServedObject(AbstractAltrmiFactory altrmiFactory,
+ AltrmiInvocationHandler invocationHandler,
+ String pubishedServiceName, String objectName, String
referenceID,
+ boolean beanOnly) {
+
+ mBeanOnly = beanOnly;
mAltrmiFactory = altrmiFactory;
mInvocationHandler = invocationHandler;
mPublishedServiceName = pubishedServiceName;
@@ -53,7 +71,7 @@
*
*/
public void registerImplObject(Object implBean) {
- mAltrmiFactory.registerReferenceObject(implBean,mReferenceID);
+ mAltrmiFactory.registerReferenceObject(implBean, mReferenceID);
}
/**
@@ -62,38 +80,46 @@
*
* @param methodSignature
* @param args
+ * @param objectName
*
* @return
*
* @throws Throwable
*
*/
- public Object altrmiProcessObjectRequestGettingFacade(String methodSignature,
Object[] args, String objectName)
- throws Throwable {
-
- MethodFacadeRequest request = new
MethodFacadeRequest(mPublishedServiceName, mObjectName, methodSignature, args,
mReferenceID, objectName);
+ public Object altrmiProcessObjectRequestGettingFacade(
+ String methodSignature, Object[] args, String objectName) throws
Throwable {
+ MethodFacadeRequest request = new
MethodFacadeRequest(mPublishedServiceName, mObjectName,
+ methodSignature, args,
+ mReferenceID,
objectName);
AltrmiReply reply = mInvocationHandler.handleInvocation(request);
if (reply.getReplyCode() == AltrmiReply.METHODFACADEREPLY) {
MethodFacadeReply mfr = (MethodFacadeReply) reply;
-
String ref = mfr.getReferenceID();
Object implBean = mAltrmiFactory.getImplObj(ref);
+
if (implBean == null) {
- BaseServedObject bo2 = new BaseServedObject(mAltrmiFactory,
mInvocationHandler, mPublishedServiceName, objectName, ref);
- Object retFacade =
mAltrmiFactory.getInstance(mPublishedServiceName, objectName ,bo2);
+ BaseServedObject bo2 = new BaseServedObject(mAltrmiFactory,
mInvocationHandler,
+ mPublishedServiceName,
objectName,
+ ref, mBeanOnly);
+ Object retFacade =
mAltrmiFactory.getInstance(mPublishedServiceName, objectName,
+ bo2, mBeanOnly);
+
bo2.registerImplObject(retFacade);
+
return retFacade;
} else {
return implBean;
}
} else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
ExceptionReply er = (ExceptionReply) reply;
+
throw er.getReplyException();
} else {
throw new AltrmiInvocationException("Internal Error : Unknown reply
type :"
- + reply.getClass().getName());
+ + reply.getClass().getName());
}
}
@@ -112,20 +138,21 @@
public Object altrmiProcessObjectRequest(String methodSignature, Object[] args)
throws Throwable {
-
- MethodRequest request = new MethodRequest(mPublishedServiceName,
mObjectName, methodSignature, args, mReferenceID);
-
+ MethodRequest request = new MethodRequest(mPublishedServiceName,
mObjectName,
+ methodSignature, args,
mReferenceID);
AltrmiReply reply = mInvocationHandler.handleInvocation(request);
if (reply.getReplyCode() == AltrmiReply.METHODREPLY) {
MethodReply or = (MethodReply) reply;
+
return or.getReplyObject();
} else if (reply.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
ExceptionReply er = (ExceptionReply) reply;
+
throw er.getReplyException();
} else {
throw new AltrmiInvocationException("Internal Error : Unknown reply
type :"
- + reply.getClass().getName());
+ + reply.getClass().getName());
}
}
@@ -141,8 +168,8 @@
*/
public void altrmiProcessVoidRequest(String methodSignature, Object[] args)
throws Throwable {
- MethodRequest request = new MethodRequest(mPublishedServiceName,
mObjectName, methodSignature, args, mReferenceID);
-
+ MethodRequest request = new MethodRequest(mPublishedServiceName,
mObjectName,
+ methodSignature, args,
mReferenceID);
AltrmiReply reply = mInvocationHandler.handleInvocation(request);
if (reply.getReplyCode() == AltrmiReply.METHODREPLY) {
@@ -155,13 +182,24 @@
throw er.getReplyException();
} else {
throw new AltrmiInvocationException("Internal Error : Unknown reply
type :"
- + reply.getClass().getName());
+ + reply.getClass().getName());
}
-
}
+ /**
+ * Method makeFacadeRefHolder
+ *
+ *
+ * @param obj
+ * @param objectName
+ *
+ * @return
+ *
+ */
public FacadeRefHolder makeFacadeRefHolder(Object obj, String objectName) {
+
String refID = mAltrmiFactory.getReferenceID(obj);
- return new FacadeRefHolder(refID,objectName);
+
+ return new FacadeRefHolder(refID, objectName);
}
}
1.2 +45 -17
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientClassAltrmiFactory.java
Index: ClientClassAltrmiFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientClassAltrmiFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClientClassAltrmiFactory.java 9 Jan 2002 19:25:53 -0000 1.1
+++ ClientClassAltrmiFactory.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -1,10 +1,14 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
- */package org.apache.commons.altrmi.client.impl;
+ */
+package org.apache.commons.altrmi.client.impl;
+
+
import org.apache.commons.altrmi.client.AltrmiFactory;
import org.apache.commons.altrmi.client.AltrmiHostContext;
@@ -17,12 +21,13 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+
/**
* Class ClientClassAltrmiFactory
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ClientClassAltrmiFactory extends AbstractAltrmiFactory {
@@ -31,26 +36,38 @@
*
*
* @param publishedServiceName
+ * @param beanOnly
*
* @return
*
* @throws AltrmiConnectionException
*
*/
- public Object lookup(String publishedServiceName)
+ public Object lookup(String publishedServiceName, boolean beanOnly)
throws AltrmiConnectionException {
- AltrmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new
LookupRequest(publishedServiceName));
+
+ AltrmiReply ar =
+ mHostContext.getInvocationHandler()
+ .handleInvocation(new LookupRequest(publishedServiceName));
+
if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
if (ar instanceof NotPublishedReply) {
- throw new AltrmiConnectionException("Service " +
publishedServiceName + " not published");
+ throw new AltrmiConnectionException("Service " +
publishedServiceName
+ + " not published");
} else {
throw new AltrmiConnectionException("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);
- bo.registerImplObject(retVal);
+ BaseServedObject baseObj = new BaseServedObject(this,
+
mHostContext.getInvocationHandler(),
+ publishedServiceName,
"Main",
+ lr.getReferenceID(),
beanOnly);
+ Object retVal = getInstance(publishedServiceName, "Main", baseObj,
beanOnly);
+
+ baseObj.registerImplObject(retVal);
+
return retVal;
}
@@ -66,24 +83,35 @@
* @throws AltrmiConnectionException
*
*/
- protected Object getInstance(String publishedServiceName, String objectName,
BaseServedObject baseServedObject) throws AltrmiConnectionException {
+ protected Object getInstance(
+ String publishedServiceName, String objectName, BaseServedObject
baseServedObject, boolean beanOnly)
+ throws AltrmiConnectionException {
+
+ String code = "2";
+
+ if (beanOnly) {
+ code = "";
+ }
+
try {
- Class clazz = Class.forName("AltrmiGenerated" + publishedServiceName +
"_" +objectName);
+ Class clazz = Class.forName("AltrmiGenerated" + code +
publishedServiceName + "_"
+ + objectName);
Constructor[] constructors = clazz.getConstructors();
- Object retVal = constructors[0].newInstance(new Object[] {
baseServedObject });
+ Object retVal = constructors[0].newInstance(new Object[]{
baseServedObject });
+
return retVal;
} catch (InvocationTargetException ite) {
throw new AltrmiConnectionException("Generated class not instantiated :
"
- +
ite.getTargetException().getMessage());
+ +
ite.getTargetException().getMessage());
} catch (ClassNotFoundException cnfe) {
throw new AltrmiConnectionException("Generated class not found during
lookup : "
- + cnfe.getMessage());
+ + cnfe.getMessage());
} catch (InstantiationException ie) {
- throw new AltrmiConnectionException("Generated class not instantiable
during lookup : "
- + ie.getMessage());
+ throw new AltrmiConnectionException(
+ "Generated class not instantiable during lookup : " +
ie.getMessage());
} catch (IllegalAccessException iae) {
- throw new AltrmiConnectionException("Illegal access to generated class
during lookup : "
- + iae.getMessage());
+ throw new AltrmiConnectionException(
+ "Illegal access to generated class during lookup : " +
iae.getMessage());
}
}
}
1.2 +69 -26
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java
Index: ServerClassAltrmiFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerClassAltrmiFactory.java 9 Jan 2002 19:25:53 -0000 1.1
+++ ServerClassAltrmiFactory.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -1,10 +1,13 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
- */package org.apache.commons.altrmi.client.impl;
+ */
+package org.apache.commons.altrmi.client.impl;
+
import org.apache.commons.altrmi.client.AltrmiFactory;
@@ -20,6 +23,7 @@
import org.apache.commons.altrmi.common.RequestFailedReply;
import java.util.HashMap;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -29,7 +33,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
@@ -40,27 +44,38 @@
*
*
* @param publishedServiceName
+ * @param beanOnly
*
* @return
*
* @throws AltrmiConnectionException
*
*/
- public Object lookup(String publishedServiceName)
+ public Object lookup(String publishedServiceName, boolean beanOnly)
throws AltrmiConnectionException {
- AltrmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new
LookupRequest(publishedServiceName));
+ AltrmiReply ar =
+ mHostContext.getInvocationHandler()
+ .handleInvocation(new LookupRequest(publishedServiceName));
+
if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
if (ar instanceof NotPublishedReply) {
- throw new AltrmiConnectionException("Service " +
publishedServiceName + " not published");
+ throw new AltrmiConnectionException("Service " +
publishedServiceName
+ + " not published");
} else {
throw new AltrmiConnectionException("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);
- bo.registerImplObject(retVal);
+ BaseServedObject baseObj = new BaseServedObject(this,
+
mHostContext.getInvocationHandler(),
+ publishedServiceName,
"Main",
+ lr.getReferenceID(),
beanOnly);
+ Object retVal = getInstance(publishedServiceName, "Main", baseObj,
beanOnly);
+
+ baseObj.registerImplObject(retVal);
+
return retVal;
}
@@ -76,47 +91,75 @@
* @throws AltrmiConnectionException
*
*/
- protected Object getInstance(String publishedServiceName, String objectName,
BaseServedObject baseServedObject) throws AltrmiConnectionException {
+ protected Object getInstance(
+ String publishedServiceName, String objectName, BaseServedObject
baseServedObject, boolean beanOnly)
+ throws AltrmiConnectionException {
+ String code = "2";
+
+ if (beanOnly) {
+ code = "";
+ }
try {
TransportedClassLoader tcl = null;
+ String beanClassName = "AltrmiGenerated" + publishedServiceName + "_" +
objectName;
+ String iiClassName = "AltrmiGenerated2" + publishedServiceName + "_" +
objectName;
+ String className = "AltrmiGenerated" + code + publishedServiceName +
"_" + objectName;
- String className = "AltrmiGenerated" + publishedServiceName + "_" +
objectName;
- if (mPublishedServiceClassLoaders.containsKey(className)) {
- tcl = (TransportedClassLoader)
mPublishedServiceClassLoaders.get(className);
+ if (mPublishedServiceClassLoaders.containsKey(beanClassName)) {
+ tcl = (TransportedClassLoader)
mPublishedServiceClassLoaders.get(beanClassName);
} else {
ClassReply cr = null;
+
try {
- AltrmiReply ar =
mHostContext.getInvocationHandler().handleInvocation(new
ClassRequest(publishedServiceName, objectName));
+ AltrmiReply ar =
+ mHostContext.getInvocationHandler()
+ .handleInvocation(new
ClassRequest(publishedServiceName, objectName));
+
if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
if (ar instanceof RequestFailedReply) {
- throw new
AltrmiConnectionException(((RequestFailedReply) ar).getFailureReason());
- } //TODO others.
+ throw new
AltrmiConnectionException(((RequestFailedReply) ar)
+ .getFailureReason());
+ } //TODO others.
}
+
cr = (ClassReply) ar;
} catch (NotPublishedException npe) {
- throw new AltrmiConnectionException("Service " +
publishedServiceName + " not published on Server");
+ throw new AltrmiConnectionException("Service " +
publishedServiceName
+ + " not published on
Server");
}
- tcl = new TransportedClassLoader(className, cr.getClassBytes());
- tcl.initialize();
- mPublishedServiceClassLoaders.put(className, tcl);
+
+ tcl = new TransportedClassLoader(this.getClass().getClassLoader());
+ tcl.add(beanClassName, cr.getBeanClassBytes());
+ try {
+ tcl.add(iiClassName, cr.getInterfaceImplClassBytes());
+ } catch (NoClassDefFoundError ncdfe) {
+ // do nothing. It's a fundamental error to have no interfaces
+ // on theclient side. This is a development issue or the user
+ // is poking with a smart tool like beanshell which can use
+ // introspection to invoke methods.
+ }
+
+ mPublishedServiceClassLoaders.put(beanClassName, tcl);
}
+
Class clazz = tcl.loadClass(className);
Constructor[] constructors = clazz.getConstructors();
- Object retVal = constructors[0].newInstance(new Object[] {
baseServedObject });
+ Object retVal = constructors[0].newInstance(new Object[]{
baseServedObject });
+
return retVal;
} catch (InvocationTargetException ite) {
throw new AltrmiConnectionException("Generated class not instantiated :
"
- +
ite.getTargetException().getMessage());
+ +
ite.getTargetException().getMessage());
} catch (ClassNotFoundException cnfe) {
throw new AltrmiConnectionException("Generated class not found during
lookup : "
- + cnfe.getMessage());
+ + cnfe.getMessage());
} catch (InstantiationException ie) {
- throw new AltrmiConnectionException("Generated class not instantiable
during lookup : "
- + ie.getMessage());
+ throw new AltrmiConnectionException(
+ "Generated class not instantiable during lookup : " +
ie.getMessage());
} catch (IllegalAccessException iae) {
- throw new AltrmiConnectionException("Illegal access to generated class
during lookup : "
- + iae.getMessage());
+ throw new AltrmiConnectionException(
+ "Illegal access to generated class during lookup : " +
iae.getMessage());
}
}
}
1.2 +20 -8
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/TransportedClassLoader.java
Index: TransportedClassLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/TransportedClassLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TransportedClassLoader.java 9 Jan 2002 19:25:53 -0000 1.1
+++ TransportedClassLoader.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -7,19 +8,30 @@
*/
package org.apache.commons.altrmi.client.impl;
-import java.util.HashMap;
+/**
+ * Class TransportedClassLoader
+ *
+ *
+ * @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
+ * @version $Revision: 1.2 $
+ */
public final class TransportedClassLoader extends ClassLoader {
- private final transient byte[] mClassBytes;
- private final transient String mClassName;
- public TransportedClassLoader(String className, byte[] classBytes) {
- mClassBytes = classBytes;
- mClassName = className;
+ public TransportedClassLoader(ClassLoader parent) {
+ super(parent);
}
- public void initialize() {
- this.defineClass(mClassName, mClassBytes, 0, mClassBytes.length);
+ /**
+ * Method add
+ *
+ *
+ * @param className
+ * @param classBytes
+ *
+ */
+ public void add(String className, byte[] classBytes) {
+ this.defineClass(className, classBytes, 0, classBytes.length);
}
}
1.2 +20 -7
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/ClassReply.java
Index: ClassReply.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/ClassReply.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassReply.java 9 Jan 2002 19:25:54 -0000 1.1
+++ ClassReply.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -14,11 +14,12 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public final class ClassReply extends AltrmiReply {
- private final byte[] mClassBytes;
+ private final byte[] mBeanClassBytes;
+ private final byte[] mInterfaceImplClassBytes;
/**
* Constructor ClassReply
@@ -27,19 +28,31 @@
* @param classBytes
*
*/
- public ClassReply(byte[] classBytes) {
- this.mClassBytes = classBytes;
+ public ClassReply(byte[] beanClassBytes, byte[] interfaceImplClassBytes) {
+ this.mBeanClassBytes = beanClassBytes;
+ this.mInterfaceImplClassBytes = interfaceImplClassBytes;
}
/**
- * Method getClassBytes
+ * Method getBeanClassBytes
*
*
* @return
*
*/
- public byte[] getClassBytes() {
- return mClassBytes;
+ public byte[] getBeanClassBytes() {
+ return mBeanClassBytes;
+ }
+
+ /**
+ * Method getInterfaceImplClassBytes
+ *
+ *
+ * @return
+ *
+ */
+ public byte[] getInterfaceImplClassBytes() {
+ return mInterfaceImplClassBytes;
}
/**
1.4 +99 -36
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/PrimarySourceGenerator.java
Index: PrimarySourceGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/PrimarySourceGenerator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PrimarySourceGenerator.java 11 Jan 2002 14:24:07 -0000 1.3
+++ PrimarySourceGenerator.java 13 Jan 2002 00:13:53 -0000 1.4
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -28,7 +29,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class PrimarySourceGenerator extends AbstractMethodHandler {
@@ -53,7 +54,8 @@
* Method setClassOrInterfacesToExpose
*
*
- * @param classesOrInterfacesToExpose
+ *
+ * @param additionalFacades
*
*/
public void setAdditionalfacades(String[] additionalFacades) {
@@ -85,49 +87,61 @@
/**
* Method generate
*
- * @param withImplInterfaces to indicate whether the resulting
- * bean should be castable to the prescribed interfaces or not.
+ *
+ * @param cL
*
*/
- public void generate(ClassLoader cL, boolean beanOnly) throws
SourceGenerationException {
+ public void generate(ClassLoader cL) throws SourceGenerationException {
// The lookupable service class source.
- makeSource(cL, beanOnly, "Main", mClassesOrInterfacesToExpose);
+ makeSource(cL, "Main", mClassesOrInterfacesToExpose);
+ makeSource2(cL, "Main", mClassesOrInterfacesToExpose);
- if ( mAdditionalFacades != null) {
+ if (mAdditionalFacades != null) {
for (int i = 0; i < mAdditionalFacades.length; i++) {
String facade = mAdditionalFacades[i];
- makeSource(cL, beanOnly, encodeClassName(facade), new String[] {
facade } );
+
+ makeSource(cL, encodeClassName(facade), new String[]{ facade });
+ makeSource2(cL, encodeClassName(facade), new String[]{ facade });
}
}
-
}
-
- public void makeSource(ClassLoader cL, boolean beanOnly, String name, String[]
classOrInterfacesToExpose) throws SourceGenerationException {
+ /**
+ * Method makeSource
+ *
+ *
+ * @param cL
+ * @param name
+ * @param classOrInterfacesToExpose
+ *
+ * @throws SourceGenerationException
+ *
+ */
+ public void makeSource(ClassLoader cL, 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 +
File.separator + "AltrmiGenerated"
- + mGenName + "_" +
name + ".java"));
+ mClassSource = new PrintWriter(new FileOutputStream(mGenDir +
File.separator
+ + "AltrmiGenerated"
+ mGenName
+ + "_" + name +
".java"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
- mClassSource
- .print("public final class AltrmiGenerated" + mGenName + "_" + name);
- if (!beanOnly) {
- mClassSource.print(" implements ");
- generateInterfaceList(classOrInterfacesToExpose);
- }
+ mClassSource.print("public class AltrmiGenerated" + mGenName + "_" + name);
mClassSource.println(" { ");
-
- mClassSource.println(" private transient
org.apache.commons.altrmi.client.impl.BaseServedObject mBaseServedObject;");
- mClassSource.println(" public AltrmiGenerated" + mGenName + "_" + name + "
(org.apache.commons.altrmi.client.impl.BaseServedObject baseServedObject) {");
+ mClassSource.println(
+ " private transient
org.apache.commons.altrmi.client.impl.BaseServedObject mBaseServedObject;");
+ mClassSource.println(
+ " public AltrmiGenerated" + mGenName + "_" + name
+ + " (org.apache.commons.altrmi.client.impl.BaseServedObject
baseServedObject) {");
mClassSource.println(" mBaseServedObject = baseServedObject;");
mClassSource.println(" }");
+
for (int x = 0; x < classOrInterfacesToExpose.length; x++) {
Class clazz = null;
@@ -147,9 +161,12 @@
methodsDone.add(methodSignature);
String rClass = method.getReturnType().getName();
+
if (!(method.getReturnType() instanceof Serializable)) {
- throw new SourceGenerationException("Return type " + rClass
+ " must be serializable");
+ throw new SourceGenerationException("Return type " + rClass
+ + " must be
serializable");
}
+
String mName = method.getName();
mClassSource.print(" public " + rClass + " " + mName + " (");
@@ -158,9 +175,12 @@
for (int i = 0; i < argTypes.length; i++) {
String cn = argTypes[i].getName();
+
if (!(argTypes[i] instanceof Serializable)) {
- throw new SourceGenerationException("Argument type " +
cn + " must be serializable");
+ throw new SourceGenerationException("Argument type " +
cn
+ + " must be
serializable");
}
+
generateParameter(cn, argTypes, i);
}
@@ -184,21 +204,23 @@
mClassSource.println(" try {");
-
if (rClass.equals("void")) {
mClassSource.println("
mBaseServedObject.altrmiProcessVoidRequest(\""
+ methodSignature.toString() +
"\",args);");
} else {
-
- boolean isFacadeRetVal =
isAdditionalFacade(method.getReturnType().getName());
+ boolean isFacadeRetVal =
+ isAdditionalFacade(method.getReturnType().getName());
if (isFacadeRetVal) {
- mClassSource.println(" Object retVal =
mBaseServedObject.altrmiProcessObjectRequestGettingFacade(\""
- + methodSignature.toString() +
"\",args,\"" + encodeClassName(rClass)+ "\");");
+ mClassSource.println(
+ " Object retVal =
mBaseServedObject.altrmiProcessObjectRequestGettingFacade(\""
+ + methodSignature.toString() + "\",args,\""
+ + encodeClassName(rClass) + "\");");
mClassSource.println(" return (" + rClass + ")
retVal;");
} else {
- mClassSource.println(" Object retVal =
mBaseServedObject.altrmiProcessObjectRequest(\""
- + methodSignature.toString() +
"\",args);");
+ mClassSource.println(
+ " Object retVal =
mBaseServedObject.altrmiProcessObjectRequest(\""
+ + methodSignature.toString() + "\",args);");
generateReturnLine(rClass);
}
}
@@ -229,6 +251,44 @@
mClassSource.close();
}
+ /**
+ * Method makeSource2
+ *
+ *
+ * @param cL
+ * @param name
+ * @param classOrInterfacesToExpose
+ *
+ * @throws SourceGenerationException
+ *
+ */
+ public void makeSource2(ClassLoader cL, String name, String[]
classOrInterfacesToExpose)
+ throws SourceGenerationException {
+
+ try {
+ PrintWriter class2Source = new PrintWriter(new FileOutputStream(mGenDir
+ +
File.separator
+ +
"AltrmiGenerated2"
+ +
mGenName + "_"
+ + name
+ ".java"));
+
+ class2Source.print("public final class AltrmiGenerated2" + mGenName +
"_" + name);
+ class2Source.print(" extends AltrmiGenerated" + mGenName + "_" + name);
+ class2Source.print(" implements ");
+ generateInterfaceList(class2Source, classOrInterfacesToExpose);
+ class2Source.println(" { ");
+ class2Source.println(
+ " public AltrmiGenerated2" + mGenName + "_" + name
+ + " (org.apache.commons.altrmi.client.impl.BaseServedObject
baseServedObject) {");
+ class2Source.println(" super(baseServedObject);");
+ class2Source.println(" }");
+ class2Source.println("}");
+ class2Source.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
private void generateThrowHandler(int i, Class[] throwsTypes) {
if (i == 0) {
@@ -258,13 +318,13 @@
}
}
- private void generateInterfaceList(String[] classOrInterfacesToExpose) {
+ private void generateInterfaceList(PrintWriter pw, String[]
classOrInterfacesToExpose) {
for (int x = 0; x < classOrInterfacesToExpose.length; x++) {
- mClassSource.print(classOrInterfacesToExpose[x]);
+ pw.print(classOrInterfacesToExpose[x]);
if (x + 1 < classOrInterfacesToExpose.length) {
- mClassSource.print(", ");
+ pw.print(", ");
}
}
}
@@ -321,7 +381,8 @@
} else if (cn.equals("byte")) {
mClassSource.println(" args[" + i + "] = new Byte(v" + i + ");");
} else if (isAdditionalFacade(cn)) {
- mClassSource.println(" args[" + i + "] =
mBaseServedObject.makeFacadeRefHolder(v" + i + ",\"" + super.encodeClassName(cn)+
"\");");
+ mClassSource.println(" args[" + i + "] =
mBaseServedObject.makeFacadeRefHolder(v"
+ + i + ",\"" + super.encodeClassName(cn) + "\");");
} else {
mClassSource.println(" args[" + i + "] = v" + i + ";");
}
@@ -351,15 +412,17 @@
}
private boolean isAdditionalFacade(String className) {
+
if (mAdditionalFacades == null) {
return false;
}
+
for (int p = 0; p < mAdditionalFacades.length; p++) {
if (className.equals(mAdditionalFacades[p])) {
return true;
}
}
+
return false;
}
-
}
1.2 +13 -10
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/SecondarySourceGenerator.java
Index: SecondarySourceGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/SecondarySourceGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SecondarySourceGenerator.java 9 Jan 2002 19:25:55 -0000 1.1
+++ SecondarySourceGenerator.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -21,12 +21,12 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class SecondarySourceGenerator extends AbstractMethodHandler {
private File mSourceClassDir;
- private String mSourceClassFileStem;
+ private String mPublishedName;
private String mGenDir;
private PrintWriter mClassSource;
@@ -42,14 +42,14 @@
}
/**
- * Method setSourceClassFileStem
+ * Method setPublishedName
*
*
- * @param sourceClassFileStem
+ * @param publishedName
*
*/
- public void setSourceClassFileStem(String sourceClassFileStem) {
- mSourceClassFileStem = sourceClassFileStem;
+ public void setPublishedName(String publishedName) {
+ mPublishedName = publishedName;
}
/**
@@ -68,12 +68,15 @@
*
*
*/
- public void generate() {
+ public void generate() throws SourceGenerationException {
String[] files = mSourceClassDir.list();
+ if (files == null) {
+ throw new SourceGenerationException("No classes to process");
+ }
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.startsWith("AltrmiGenerated" + mPublishedName) |
filename.startsWith("AltrmiGenerated2" + mPublishedName)) {
if (filename.endsWith(".class")) {
String name = filename.substring(0,filename.length() - 6);
makeSource(name, file);
@@ -88,7 +91,7 @@
try {
mClassSource = new PrintWriter(new FileOutputStream(mGenDir +
File.separator
- + genName +
".java"));
+ + "BaseMobile" +
genName + ".java"));
FileInputStream fis = new FileInputStream(sourceFile);
int size = fis.available();
@@ -101,7 +104,7 @@
}
mClassSource
- .println("public final class " + genName
+ .println("public final class BaseMobile" + genName
+ " extends
org.apache.commons.altrmi.server.impl.BaseMobileClass { ");
mClassSource.println(" public byte[] getClassBytes() { ");
mClassSource.println(" return new byte[] { ");
1.2 +12 -6
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiClassInternTask.java
Index: AltrmiClassInternTask.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiClassInternTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AltrmiClassInternTask.java 9 Jan 2002 19:25:55 -0000 1.1
+++ AltrmiClassInternTask.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -10,6 +10,7 @@
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.commons.altrmi.generator.SecondarySourceGenerator;
+import org.apache.commons.altrmi.generator.SourceGenerationException;
import java.io.File;
import java.io.IOException;
@@ -18,7 +19,7 @@
private String mGenDir;
private String mSourceClassDir;
- private String mSourceClassFileStem;
+ private String mPublishedName;
public AltrmiClassInternTask() {
}
@@ -27,8 +28,8 @@
mSourceClassDir = sourceClassDir;
}
- public void setSourceclassfilestem(String sourceClassFileStem) {
- mSourceClassFileStem = sourceClassFileStem;
+ public void setPublishedName(String publishedName) {
+ mPublishedName = publishedName;
}
public void setGendir(String genDir) {
@@ -42,13 +43,18 @@
if (mSourceClassDir == null) {
throw new BuildException("Specify the directories of the class 'source'
files");
}
- if (mSourceClassFileStem == null) {
+ if (mPublishedName == null) {
throw new BuildException("Specify the stem name of class 'source'
files");
}
SecondarySourceGenerator sg = new SecondarySourceGenerator();
sg.setGenDir(mGenDir);
sg.setSourceClassDir( new File(mSourceClassDir));
- sg.setSourceClassFileStem(mSourceClassFileStem);
- sg.generate();
+ sg.setPublishedName(mPublishedName);
+
+ try {
+ sg.generate();
+ } catch (SourceGenerationException e) {
+ throw new BuildException("Some problem interning " + e.getMessage(), e);
+ }
}
}
1.3 +1 -6
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiInterfaceTask.java
Index: AltrmiInterfaceTask.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/generator/ant/AltrmiInterfaceTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AltrmiInterfaceTask.java 11 Jan 2002 14:24:07 -0000 1.2
+++ AltrmiInterfaceTask.java 13 Jan 2002 00:13:53 -0000 1.3
@@ -25,7 +25,6 @@
protected String[] mAdditionalFacades;
protected String mGenDir;
protected String mGenName;
- protected boolean mBeanOnly;
protected Path classpath;
public AltrmiInterfaceTask() {
@@ -55,10 +54,6 @@
mGenDir = genDir;
}
- public void setBeanonly(String yesNo) {
- mBeanOnly = yesNo.equals("yes");
- }
-
public void setGenname(String genName) {
this.mGenName = genName;
}
@@ -105,7 +100,7 @@
cL = this.getClass().getClassLoader();
}
- sg.generate(cL, mBeanOnly);
+ sg.generate(cL);
} catch (SourceGenerationException sge) {
throw new BuildException(sge.getMessage());
}
1.2 +2 -1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/ClassRetriever.java
Index: ClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/ClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassRetriever.java 9 Jan 2002 19:25:55 -0000 1.1
+++ ClassRetriever.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -10,6 +10,7 @@
public interface ClassRetriever {
- byte[] getBytes(String publishedName) throws AltrmiClassRetrievalException;
+ byte[] getBeanBytes(String publishedName) throws AltrmiClassRetrievalException;
+ byte[] getInterfaceImplementationBytes(String publishedName) throws
AltrmiClassRetrievalException;
}
1.2 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
Index: AbstractServer.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractServer.java 9 Jan 2002 19:25:55 -0000 1.1
+++ AbstractServer.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -46,7 +46,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class AbstractServer extends AbstractMethodHandler implements
AltrmiServer {
@@ -297,7 +297,7 @@
try {
ClassRequest cr = (ClassRequest) request;
String publishedThing = cr.getPublishedServiceName() + "_" +
cr.getObjectName();
- return new ClassReply(mClassRetriever.getBytes(publishedThing));
+ return new ClassReply(mClassRetriever.getBeanBytes(publishedThing),
mClassRetriever.getInterfaceImplementationBytes(publishedThing));
} catch (AltrmiClassRetrievalException e) {
return new RequestFailedReply(e.getMessage());
1.2 +9 -19
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/BaseMobileClassRetriever.java
Index: BaseMobileClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/BaseMobileClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseMobileClassRetriever.java 9 Jan 2002 19:25:55 -0000 1.1
+++ BaseMobileClassRetriever.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -1,3 +1,4 @@
+
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -18,37 +19,26 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class BaseMobileClassRetriever implements ClassRetriever {
+public class BaseMobileClassRetriever extends AbstractClassRetriever {
- /**
- * Method getBytes
- *
- *
- * @param publishedName
- *
- * @return
- *
- * @throws AltrmiClassRetrievalException
- *
- */
- public byte[] getBytes(String publishedName) throws
AltrmiClassRetrievalException {
+ protected byte[] getThingBytes(String thingName) throws
AltrmiClassRetrievalException {
try {
- Class clazz = Class.forName("AltrmiGenerated" + publishedName);
+ Class clazz = Class.forName("BaseMobile" + thingName);
BaseMobileClass bmc = (BaseMobileClass) clazz.newInstance();
return bmc.getClassBytes();
} catch (ClassNotFoundException cnfe) {
throw new AltrmiClassRetrievalException("Generated class not found
during lookup : "
- + cnfe.getMessage());
+ + cnfe.getMessage());
} catch (InstantiationException ie) {
- throw new AltrmiClassRetrievalException("Generated class not
instantiable during lookup : "
- + ie.getMessage());
+ throw new AltrmiClassRetrievalException(
+ "Generated class not instantiable during lookup : " +
ie.getMessage());
} catch (IllegalAccessException iae) {
- throw new AltrmiClassRetrievalException("Illegal access to generated
class during lookup : "
- + iae.getMessage());
+ throw new AltrmiClassRetrievalException(
+ "Illegal access to generated class during lookup : " +
iae.getMessage());
}
}
}
1.2 +5 -5
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/JarFileClassRetriever.java
Index: JarFileClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/JarFileClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JarFileClassRetriever.java 9 Jan 2002 19:25:55 -0000 1.1
+++ JarFileClassRetriever.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -26,9 +26,9 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class JarFileClassRetriever implements ClassRetriever {
+public class JarFileClassRetriever extends AbstractClassRetriever {
private URLClassLoader mURLClassLoader;
@@ -88,20 +88,20 @@
}
/**
- * Method getBytes
+ * Method getThingBytes
*
*
- * @param publishedName
+ * @param thingName
*
* @return
*
* @throws AltrmiClassRetrievalException
*
*/
- public byte[] getBytes(String publishedName) throws
AltrmiClassRetrievalException {
+ public byte[] getThingBytes(String thingName) throws
AltrmiClassRetrievalException {
try {
- URL rsc = mURLClassLoader.findResource(publishedName);
+ URL rsc = mURLClassLoader.findResource(thingName);
InputStream is = rsc.openStream();
byte[] bytes = new byte[is.available()];
1.2 +3 -14
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/NoClassRetriever.java
Index: NoClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/NoClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NoClassRetriever.java 10 Jan 2002 11:17:03 -0000 1.1
+++ NoClassRetriever.java 13 Jan 2002 00:13:53 -0000 1.2
@@ -16,23 +16,12 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class NoClassRetriever implements ClassRetriever {
-
- /**
- * Method getBytes
- *
- *
- * @param publishedName
- *
- * @return
- *
- * @throws AltrmiClassRetrievalException
- *
- */
- public byte[] getBytes(String publishedName) throws
AltrmiClassRetrievalException {
+public class NoClassRetriever extends AbstractClassRetriever {
+ protected byte[] getThingBytes(String thingName) throws
AltrmiClassRetrievalException {
throw new AltrmiClassRetrievalException("This AltRMI server does not
support class forwarding");
}
+
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractClassRetriever.java
Index: AbstractClassRetriever.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.commons.altrmi.server.impl;
import org.apache.commons.altrmi.server.ClassRetriever;
import org.apache.commons.altrmi.server.AltrmiClassRetrievalException;
public abstract class AbstractClassRetriever implements ClassRetriever {
public final byte[] getBeanBytes(String publishedName) throws
AltrmiClassRetrievalException {
return getThingBytes("AltrmiGenerated" + publishedName);
}
public final byte[] getInterfaceImplementationBytes(String publishedName) throws
AltrmiClassRetrievalException {
return getThingBytes("AltrmiGenerated2" + publishedName);
}
protected abstract byte[] getThingBytes(String thingName) throws
AltrmiClassRetrievalException;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>