hammant 2002/07/15 14:52:20
Modified: altrmi/src/java/org/apache/excalibur/altrmi/generator
AbstractProxyGenerator.java
BCELProxyGeneratorImpl.java ProxyGeneratorImpl.java
altrmi/src/java/org/apache/excalibur/altrmi/generator/ant
AltrmiProxyTask.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers
AbstractClassRetriever.java
AbstractDynamicGeneratorClassRetriever.java
BcelDynamicGeneratorClassRetriever.java
JarFileClassRetriever.java
JavacDynamicGeneratorClassRetriever.java
NoClassRetriever.java
Log:
One step closer to checkstyle compliance for two packages.
Revision Changes Path
1.2 +12 -6
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/AbstractProxyGenerator.java
Index: AbstractProxyGenerator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/AbstractProxyGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractProxyGenerator.java 14 Jul 2002 23:12:44 -0000 1.1
+++ AbstractProxyGenerator.java 15 Jul 2002 21:52:19 -0000 1.2
@@ -198,6 +198,7 @@
*
*
* @param clazz the class
+ * @return true if the class is one of the designated facades
*
*/
protected boolean isAdditionalFacade( Class clazz )
@@ -223,6 +224,12 @@
return false;
}
+ /**
+ * Creates the Java-Source type of the string.
+ *
+ * @param rClass the class to get a type for
+ * @return the class type
+ */
protected String getClassType( Class rClass )
{
@@ -239,10 +246,10 @@
}
/**
- * Method generateSrc
+ * Gernerate the source for the proxy class.
*
- *
- * @param classLoader
+ * @param classLoader the classloader to use while making the source.
+ * @throws ProxyGenerationException if an error during generation
*
*/
public void generateSrc( ClassLoader classLoader ) throws
ProxyGenerationException
@@ -251,8 +258,7 @@
}
/**
- * Method generateDeferredClasses
- *
+ * Generate the deferred classes.
*
*/
public void generateDeferredClasses()
1.5 +208 -142
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/BCELProxyGeneratorImpl.java
Index: BCELProxyGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/BCELProxyGeneratorImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BCELProxyGeneratorImpl.java 14 Jul 2002 23:12:44 -0000 1.4
+++ BCELProxyGeneratorImpl.java 15 Jul 2002 21:52:19 -0000 1.5
@@ -37,7 +37,7 @@
/**
* Class BCElProxyGeneratorImpl
* This class generates Altrmi stubs using Jakarta BCEL library.
- *
+ *
* HOWTO: Use 'javap' to read the bytecodes of the stubs generated
* by using the original stub-generator(which generates pure java code).
*
@@ -47,18 +47,21 @@
public class BCELProxyGeneratorImpl
extends AbstractProxyGenerator
{
-
- //bcel
+
+ //bcel
private static final String STUB_PREFIX = "AltrmiGenerated";
private InstructionFactory m_factory;
private ConstantPoolGen m_constantsPool;
private ClassGen m_classGen;
private ArrayList m_internalFieldRepresentingClasses;
- /*
- * @see ProxyGenerator#generateClass(ClassLoader)
+ /**
+ * Generate the class.
+ *
+ * @param classLoader the classloader to use during generation.
+ * @see
org.apache.excalibur.altrmi.common.ProxyGenerator#generateClass(ClassLoader)
*/
- public void generateClass(ClassLoader cL)
+ public void generateClass(ClassLoader classLoader)
{
//create the Main Stubs:
@@ -68,7 +71,7 @@
STUB_PREFIX + getGenName() + "_Main",
getInterfacesToExpose());
- //Create the Additional Facades
+ //Create the Additional Facades
if (getAdditionalFacades() != null)
{
for (int i = 0; i < getAdditionalFacades().length; i++)
@@ -89,29 +92,32 @@
/**
* Method generateAltrmiProxyClass.
- * Create AltrmiProxy Implementation with all interface methods
+ * Create AltrmiProxy Implementation with all interface methods
* Generating AltrmiGeneratedGENNAME_Main class
- * @param mGeneratedClassName
- * @param interfacesToStubify
+ * @param mGeneratedClassName the name of the class to generate.
+ * @param interfacesToStubify the interfaces to stubify.
*/
protected void generateAltrmiProxyClass(
String mGeneratedClassName,
Class[] interfacesToStubify)
{
- //Start creating class
+ //Start creating class
createNewClassDeclaration(mGeneratedClassName);
/******** CONSTRUCTOR **************/
//create constructor that takes ProxyHelper
createConstructor(mGeneratedClassName);
/******** FIELDS *************/
- //create fields
+ //create fields
createFields();
/******** METHODS *************/
- //create fields
+ //create fields
createAltrmiGetReferenceIDMethod(mGeneratedClassName);
createHelperMethodForDotClassCalls(mGeneratedClassName);
createInterfaceMethods(mGeneratedClassName, interfacesToStubify);
- //TODO://Finally finally fInally "DUMP" the class file that we deligently
prepared somewhere
+ /*
+ TODO://Finally finally fInally "DUMP" the class file that we
+ deligently prepared somewhere
+ */
FileOutputStream fos = null;
try
{
@@ -134,9 +140,9 @@
* Create the Stub Class purely implementing the Interface and
* inheriting the implementation from the helper class
* Generating AltrmiGenerated2GENNAME_Main class
- * @param generatedClassName2
- * @param generatedClassName
- * @param interfacesToStubify
+ * @param generatedClassName2 the implementation class name
+ * @param generatedClassName the bean class name
+ * @param interfacesToStubify the interfaces to turn into stubs.
*/
protected void generateAltrmiProxyClass2(
String generatedClassName2,
@@ -148,7 +154,7 @@
generatedClassName2,
generatedClassName,
interfacesToStubify);
- //create the constructor
+ //create the constructor
createConstructor2(generatedClassName2, generatedClassName);
try
{
@@ -173,15 +179,16 @@
/**
* Method createAndInitializeClass.
* This method starts creating the class.
+ * @param generatedClassName the bean class name
*/
- protected void createNewClassDeclaration(String mGeneratedClassName)
+ protected void createNewClassDeclaration(String generatedClassName)
{
m_classGen =
new ClassGen(
- mGeneratedClassName,
+ generatedClassName,
"java.lang.Object",
- mGeneratedClassName + ".java",
+ generatedClassName + ".java",
Constants.ACC_PUBLIC | Constants.ACC_SUPER,
new String[] { "org.apache.excalibur.altrmi.client.AltrmiProxy" });
m_constantsPool = m_classGen.getConstantPool();
@@ -191,32 +198,40 @@
}
/**
* Method createNewClassDeclaration2.
- * Create a class which extends a class contained the impl of the Interface
and
+ * Create a class which extends a class contained the impl of the Interface
and
* and implements the interface
+ * @param generatedClassName2 the implementation class name
+ * @param generatedClassName the bean class name
+ * @param interfacesToStubify the interfaces to turn into stubs.
+
*/
protected void createNewClassDeclaration2(
- String mGeneratedClassName2,
- String mGeneratedClassName,
+ String generatedClassName2,
+ String generatedClassName,
Class[] interfacesToStubify)
{
- String[] mInterafacesToImplement = new String[interfacesToStubify.length];
- for (int i = 0; i < mInterafacesToImplement.length; i++)
- mInterafacesToImplement[i] = interfacesToStubify[i].getName();
+ String[] interafacesToImplement = new String[interfacesToStubify.length];
+ for (int i = 0; i < interafacesToImplement.length; i++)
+ {
+ interafacesToImplement[i] = interfacesToStubify[i].getName();
+ }
m_classGen =
new ClassGen(
- mGeneratedClassName2,
- mGeneratedClassName,
- mGeneratedClassName2 + ".java",
+ generatedClassName2,
+ generatedClassName,
+ generatedClassName2 + ".java",
Constants.ACC_PUBLIC | Constants.ACC_FINAL | Constants.ACC_SUPER,
- mInterafacesToImplement);
+ interafacesToImplement);
m_constantsPool = m_classGen.getConstantPool();
m_factory = new InstructionFactory(m_classGen, m_constantsPool);
}
/**
* Method createConstructor.
* This method adds a constructor that takes in a ProxyHelper Instance
+ * @param generatedClassName the bean class name
+
*/
- protected void createConstructor(String mGeneratedClassName)
+ protected void createConstructor(String generatedClassName)
{
InstructionList il = new InstructionList();
MethodGen method =
@@ -226,7 +241,7 @@
new Type[] { new
ObjectType("org.apache.excalibur.altrmi.client.ProxyHelper")},
new String[] { "arg0" },
"<init>",
- mGeneratedClassName,
+ generatedClassName,
il,
m_constantsPool);
InstructionHandle ih0 = il.append(m_factory.createLoad(Type.OBJECT, 0));
@@ -241,7 +256,7 @@
il.append(m_factory.createLoad(Type.OBJECT, 1));
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
"mProxyHelper",
new ObjectType("org.apache.excalibur.altrmi.client.ProxyHelper"),
Constants.PUTFIELD));
@@ -254,10 +269,12 @@
/**
* Method createConstructor2.
+ * @param generatedClassName2 the implementation class name
+ * @param generatedClassName the bean class name
*/
protected void createConstructor2(
- String mGeneratedClassName2,
- String mGeneratedClassName)
+ String generatedClassName2,
+ String generatedClassName)
{
InstructionList il = new InstructionList();
MethodGen method =
@@ -267,14 +284,14 @@
new Type[] { new
ObjectType("org.apache.excalibur.altrmi.client.ProxyHelper")},
new String[] { "arg0" },
"<init>",
- mGeneratedClassName2,
+ generatedClassName2,
il,
m_constantsPool);
InstructionHandle ih0 = il.append(m_factory.createLoad(Type.OBJECT, 0));
il.append(m_factory.createLoad(Type.OBJECT, 1));
il.append(
m_factory.createInvoke(
- mGeneratedClassName,
+ generatedClassName,
"<init>",
Type.VOID,
new Type[] { new
ObjectType("org.apache.excalibur.altrmi.client.ProxyHelper")},
@@ -291,7 +308,7 @@
* =================adding===============
* private transient org.apache.excalibur.altrmi.client.ProxyHelper
mProxyHelper;
* =================adding===============
- * Add
+ * Add
*/
protected void createFields()
{
@@ -306,7 +323,7 @@
}
/**
- * Method createAltrmiGetReferenceIDMethod.
+ * Method createAltrmiGetReferenceIDMethod.
* =================adding=====================================
* public Long altrmiGetReferenceID(Object factoryThatIsAsking) {
* return mProxyHelper.getReferenceID(factoryThatIsAsking);
@@ -353,11 +370,12 @@
/**
* Method createHelperMethodForDotClassCalls.
- * This class creates a method class$(String) which is used
+ * This class creates a method class$(String) which is used
* during SomeClass.class instruction
- *
+ *
+ * @param generatedClassName the bean class name
*/
- protected void createHelperMethodForDotClassCalls(String mGeneratedClassName)
+ protected void createHelperMethodForDotClassCalls(String generatedClassName)
{
InstructionList il = new InstructionList();
MethodGen method =
@@ -367,7 +385,7 @@
new Type[] { Type.STRING },
new String[] { "arg0" },
"class$",
- mGeneratedClassName,
+ generatedClassName,
il,
m_constantsPool);
InstructionHandle ih0 = il.append(m_factory.createLoad(Type.OBJECT, 0));
@@ -443,19 +461,20 @@
/**
* Method createInterfaceMethod.
* Add the java.lang.reflect.Method wrapper into the stub
- * @param m
+ * @param generatedClassName the bean class name
+ * @param mth the method
*/
- protected void createInterfaceMethod(String mGeneratedClassName, Method m)
+ protected void createInterfaceMethod(String generatedClassName, Method mth)
{
InstructionList il = new InstructionList();
MethodGen method =
new MethodGen(
Constants.ACC_PUBLIC,
- getReturnType(m),
- getArguments(m),
- getArgumentNames(m),
- m.getName(),
- mGeneratedClassName,
+ getReturnType(mth),
+ getArguments(mth),
+ getArgumentNames(mth),
+ mth.getName(),
+ generatedClassName,
il,
m_constantsPool);
@@ -469,11 +488,11 @@
* Declaration of Arrays
* =======================
* Object[] args = new Object[__number__of__arguments];
- * Class[] argClasses = new Class[__number__of__arguments];
+ * Class[] argClasses = new Class[__number__of__arguments];
*/
int variableIndex, numberOfArguments;
- Class[] paramTypes = m.getParameterTypes();
+ Class[] paramTypes = mth.getParameterTypes();
numberOfArguments = paramTypes.length;
variableIndex = getFreeIndexToStart(paramTypes);
InstructionHandle ih0 = il.append(new PUSH(m_constantsPool,
numberOfArguments));
@@ -492,7 +511,7 @@
* args[0] = v0;
* argClasses[0]=v0Class.class
*/
- //Used for adjustment of double/long datatype:
+ //Used for adjustment of double/long datatype:
Type previousType = null;
int loadIndex = 0;
for (int i = 0; i < numberOfArguments; i++)
@@ -504,7 +523,9 @@
//adjust for any previous wider datatype (double/long)
if (previousType != null
&& (previousType == Type.DOUBLE || previousType == Type.LONG))
+ {
++loadIndex;
+ }
if (paramTypes[i].isPrimitive())
{
il.append(m_factory.createNew(getJavaWrapperClass(className)));
@@ -528,18 +549,24 @@
{
int index = className.lastIndexOf('[');
if (className.charAt(index + 1) == 'L')
+ {
encodedFieldName =
- "array$"
- + className.substring(1 + index, className.length()
- 1).replace('.', '$');
+ "array$" + className.substring(1 + index,
+ className.length() - 1).replace('.', '$');
+ }
else
+ {
encodedFieldName =
"array$" + className.substring(1 + index,
className.length());
+ }
}
else
+ {
encodedFieldName = "class$" + className.replace('.', '$');
-
+ }
+
addField(encodedFieldName);
- // ******** TODO assign the obj reference
+ // ******** TODO assign the obj reference
il.append(m_factory.createLoad(Type.OBJECT, variableIndex - 1));
il.append(new PUSH(m_constantsPool, i));
il.append(m_factory.createLoad(Type.OBJECT, ++loadIndex));
@@ -550,7 +577,7 @@
il.append(new PUSH(m_constantsPool, i));
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedFieldName,
new ObjectType("java.lang.Class"),
Constants.GETSTATIC));
@@ -559,7 +586,7 @@
il.append(ifnull);
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedFieldName,
new ObjectType("java.lang.Class"),
Constants.GETSTATIC));
@@ -573,7 +600,7 @@
il.append(
m_factory.createInvoke(
- mGeneratedClassName,
+ generatedClassName,
"class$",
new ObjectType("java.lang.Class"),
new Type[] { Type.STRING },
@@ -581,7 +608,7 @@
il.append(InstructionConstants.DUP);
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedFieldName,
new ObjectType("java.lang.Class"),
Constants.PUTSTATIC));
@@ -592,51 +619,55 @@
previousType = getBCELPrimitiveType(className);
}
- /* Within the stub put the
+ /* Within the stub put the
* Call processObjectRequest on the instance ProxyHelper held within the
stub
* Thus,
* Injecting the following
* ================================================
- * try
+ * try
* {
- * Object retVal = mProxyHelper.processObjectRequest("foo1(int,
float, java.lang.String, java.lang.Integer)",args,argClasses);
+ * Object retVal = mProxyHelper.processObjectRequest("foo1(int,
+ float, java.lang.String, java.lang.Integer)",args,argClasses);
* return (java.lang.String) retVal;
- * }
- * catch (Throwable t)
+ * }
+ * catch (Throwable t)
* {
- * if (t instanceof RuntimeException)
- * {
+ * if (t instanceof RuntimeException)
+ * {
* throw (RuntimeException) t;
- * } else if (t instanceof Error)
- * {
+ * } else if (t instanceof Error)
+ * {
* throw (Error) t;
- * } else
- * {
- * t.printStackTrace();
- * throw new
org.apache.excalibur.altrmi.common.AltrmiInvocationException("Should never get here: "
+ t.getMessage());
- * }
+ * } else
+ * {
+ * t.printStackTrace();
+ * throw new org.apache.excalibur.altrmi.common.
+ AltrmiInvocationException("Should never get here:"
+t.getMessage());
+ * }
* }
* ================================================
*/
InstructionHandle ihe1 = il.append(m_factory.createLoad(Type.OBJECT, 0));
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
"mProxyHelper",
new ObjectType("org.apache.excalibur.altrmi.client.ProxyHelper"),
Constants.GETFIELD));
// **** Check if the return type is facade ***
- Class returnClass=m.getReturnType();
+ Class returnClass=mth.getReturnType();
if(returnClass.isArray())
+ {
returnClass=returnClass.getComponentType();
-
- if (isAdditionalFacade(m.getReturnType()))
+ }
+
+ if (isAdditionalFacade(mth.getReturnType()))
{
String encodedReturnClassName="class$" + encodeClassName(returnClass);
addField(encodedReturnClassName);
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedReturnClassName,
new ObjectType("java.lang.Class"),
Constants.GETSTATIC));
@@ -645,20 +676,20 @@
il.append(ifnullReturnClass);
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedReturnClassName,
new ObjectType("java.lang.Class"),
Constants.GETSTATIC));
BranchInstruction gotoReturnClass =
m_factory.createBranchInstruction(Constants.GOTO, null);
il.append(gotoReturnClass);
-
+
InstructionHandle ihPushMethodName =
il.append(new PUSH(m_constantsPool, returnClass.getName()));
ifnullReturnClass.setTarget(ihPushMethodName);
il.append(
m_factory.createInvoke(
- mGeneratedClassName,
+ generatedClassName,
"class$",
new ObjectType("java.lang.Class"),
new Type[] { Type.STRING },
@@ -666,12 +697,12 @@
il.append(InstructionConstants.DUP);
il.append(
m_factory.createFieldAccess(
- mGeneratedClassName,
+ generatedClassName,
encodedReturnClassName,
new ObjectType("java.lang.Class"),
Constants.PUTSTATIC));
InstructionHandle ihPushSignature =
- il.append(new PUSH(m_constantsPool, getMethodSignature(m)));
+ il.append(new PUSH(m_constantsPool, getMethodSignature(mth)));
gotoReturnClass.setTarget(ihPushSignature);
il.append(m_factory.createLoad(Type.OBJECT, variableIndex-1));
il.append(new PUSH(m_constantsPool, encodeClassName( getClassType(
returnClass ) )));
@@ -689,8 +720,8 @@
}
else
{
- //method signature = METHODNAME(arguments....)
- il.append(new PUSH(m_constantsPool, getMethodSignature(m)));
+ //method signature = METHODNAME(arguments....)
+ il.append(new PUSH(m_constantsPool, getMethodSignature(mth)));
variableIndex -= 2;
il.append(m_factory.createLoad(Type.OBJECT, ++variableIndex));
il.append(m_factory.createLoad(Type.OBJECT, ++variableIndex));
@@ -709,9 +740,9 @@
il.append(m_factory.createLoad(Type.OBJECT, variableIndex));
InstructionHandle ihe2;
- if (m.getReturnType().isPrimitive())
+ if (mth.getReturnType().isPrimitive())
{
- if (getBCELPrimitiveType(m.getReturnType().getName()) == Type.VOID)
+ if (getBCELPrimitiveType(mth.getReturnType().getName()) == Type.VOID)
{
ihe2 = il.append(m_factory.createReturn(Type.VOID));
}
@@ -719,31 +750,30 @@
{
il.append(
m_factory.createCheckCast(
- new
ObjectType(getJavaWrapperClass(m.getReturnType().getName()))));
+ new
ObjectType(getJavaWrapperClass(mth.getReturnType().getName()))));
il.append(
m_factory.createInvoke(
- getJavaWrapperClass(m.getReturnType().getName()),
- m.getReturnType().getName() + "Value",
- getBCELPrimitiveType(m.getReturnType().getName()),
+ getJavaWrapperClass(mth.getReturnType().getName()),
+ mth.getReturnType().getName() + "Value",
+ getBCELPrimitiveType(mth.getReturnType().getName()),
Type.NO_ARGS,
Constants.INVOKEVIRTUAL));
- ihe2 =
- il.append(
-
m_factory.createReturn(getBCELPrimitiveType(m.getReturnType().getName())));
+ ihe2 = il.append(
+
m_factory.createReturn(getBCELPrimitiveType(mth.getReturnType().getName())));
}
}
else
{
il.append(
- m_factory.createCheckCast(new
ObjectType(m.getReturnType().getName())));
+ m_factory.createCheckCast(new
ObjectType(mth.getReturnType().getName())));
ihe2 = il.append(m_factory.createReturn(Type.OBJECT));
}
InstructionHandle ihe3 =
il.append(m_factory.createStore(Type.OBJECT, variableIndex));
- //add custom exceptionHandling here
- Class[] exceptionClasses = m.getExceptionTypes();
+ //add custom exceptionHandling here
+ Class[] exceptionClasses = mth.getExceptionTypes();
InstructionHandle customHandler = null;
BranchInstruction ifCustomExceptionBranch = null;
for (int i = 0; i < exceptionClasses.length; i++)
@@ -752,7 +782,9 @@
customHandler = il.append(m_factory.createLoad(Type.OBJECT,
variableIndex));
//create the series of custom exception handlers for the classes
if (ifCustomExceptionBranch != null)
+ {
ifCustomExceptionBranch.setTarget(customHandler);
+ }
il.append(
new INSTANCEOF(
m_constantsPool.addClass(new
ObjectType(exceptionClasses[i].getName()))));
@@ -768,7 +800,9 @@
InstructionHandle defaultExceptionHandler =
il.append(m_factory.createLoad(Type.OBJECT, variableIndex));
if (customHandler != null)
+ {
ifCustomExceptionBranch.setTarget(defaultExceptionHandler);
+ }
il.append(
new INSTANCEOF(
m_constantsPool.addClass(new
ObjectType("java.lang.RuntimeException"))));
@@ -857,15 +891,15 @@
/**
* Method getFreeIndexToStart.
* Returns the index to start allocating the subsequent stack variables
- * @param ca
- * @return int
+ * @param classes the classes
+ * @return int the index
*/
- protected int getFreeIndexToStart(Class[] ca)
+ protected int getFreeIndexToStart(Class[] classes)
{
int index = 0;
- for (int i = 0; i < ca.length; i++)
+ for (int i = 0; i < classes.length; i++)
{
- if (getBCELType(ca[i]) == Type.DOUBLE) //||
getBCELType(ca[i])==Type.LONG)
+ if (getBCELType(classes[i]) == Type.DOUBLE) //||
getBCELType(ca[i])==Type.LONG)
{
index += 2;
}
@@ -876,16 +910,18 @@
}
/**
* Method getArguments.
- * Convert the arguments of the method
+ * Convert the arguments of the method
* into equivalent BCEL datatypes
- * @param m
- * @return Type[]
+ * @param method the method for which arguments are needed.
+ * @return Type[] an array of types
*/
- protected Type[] getArguments(Method m)
+ protected Type[] getArguments(Method method)
{
- Class[] classes = m.getParameterTypes();
+ Class[] classes = method.getParameterTypes();
if (classes.length == 0)
+ {
return Type.NO_ARGS;
+ }
Type[] types = new Type[classes.length];
for (int i = 0; i < classes.length; i++)
@@ -898,23 +934,23 @@
/**
* Method getReturnType.
* Convert the returnType of the method into BCEL datatype
- * @param m
- * @return Type
+ * @param method the method
+ * @return Type the type
*/
- protected Type getReturnType(Method m)
+ protected Type getReturnType(Method method)
{
- return getBCELType(m.getReturnType());
+ return getBCELType(method.getReturnType());
}
/**
* Method getArgumentNames.
* The arguments are arg0,arg1,.....
- * @param m
+ * @param method the method
* @return String[]
*/
- protected String[] getArgumentNames(Method m)
+ protected String[] getArgumentNames(Method method)
{
- Class[] classes = m.getParameterTypes();
+ Class[] classes = method.getParameterTypes();
String[] args = new String[classes.length];
for (int i = 0; i < classes.length; i++)
{
@@ -926,28 +962,29 @@
/**
* Method getBCELType.
* Maps the java datatype and the BCEL datatype
- * @param c
- * @return Type
+ * @param clazz the class
+ * @return Type the type
*/
- protected Type getBCELType(Class c)
+ protected Type getBCELType(Class clazz)
{
- if (c.isPrimitive())
+ if (clazz.isPrimitive())
{
- return getBCELPrimitiveType(c.getName());
+ return getBCELPrimitiveType(clazz.getName());
}
- else if (!c.isArray())
+ else if (!clazz.isArray())
{
- return new ObjectType(c.getName());
+ return new ObjectType(clazz.getName());
}
else
{
- String className = c.getName();
+ String className = clazz.getName();
int index = className.lastIndexOf('[');
int arrayDepth = className.indexOf('[') - className.lastIndexOf('[') +
1;
if (className.charAt(index + 1) == 'L')
{
- return new ArrayType(new
ObjectType(c.getComponentType().getName()), arrayDepth);
+ return new ArrayType(
+ new ObjectType(clazz.getComponentType().getName()), arrayDepth);
}
return new ArrayType(
@@ -959,9 +996,9 @@
/**
* Method getBCELPrimitiveType.
- * Returns the BCEL Type given the Class Name
- * @param javaDataType
- * @return Type
+ * Returns the BCEL Type given the Class Name
+ * @param javaDataType the java data type
+ * @return Type the BCEL type
*/
protected Type getBCELPrimitiveType(String javaDataType)
{
@@ -1009,10 +1046,10 @@
/**
* Method getJavaWrapperClass.
- * Returns the String representing the Wrapper class given the
+ * Returns the String representing the Wrapper class given the
* primitive datatype
- * @param javaDataType
- * @return String
+ * @param javaDataType the java data type
+ * @return String the JavaSource type.
*/
protected String getJavaWrapperClass(String javaDataType)
{
@@ -1021,9 +1058,13 @@
case 'b' :
if (javaDataType.charAt(1) == 'o')
+ {
return "java.lang.Boolean";
+ }
else
+ {
return "java.lang.Byte";
+ }
case 'c' :
case 'C' :
return "java.lang.Character";
@@ -1056,11 +1097,16 @@
return null; //never occurs;
}
+ /**
+ *
+ * @param encodedFieldName the encoded field name
+ */
protected void addField(String encodedFieldName)
{
if (!m_internalFieldRepresentingClasses.contains(encodedFieldName))
{
- //System.out.println("method."+method.getName()+".addingfield[" +
_encodedFieldName + "]");
+ //System.out.println("method."+method.getName()+".addingfield["
+ // + _encodedFieldName + "]");
FieldGen field =
new FieldGen(
Constants.ACC_STATIC,
@@ -1072,8 +1118,12 @@
}
}
-
- //++++++++++++++++++testing
+
+ /**
+ *
+ * @param il the instruction list
+ * @param msg the message
+ */
protected void createTestMethod(InstructionList il, String msg)
{
il.append(
@@ -1092,23 +1142,39 @@
Constants.INVOKEVIRTUAL));
}
- protected void debug(String prefix, Object[] a)
+ /**
+ * A debugging method
+ *
+ * @param prefix the prefix to print
+ * @param objArray the object array to print.
+ */
+ protected void debug(String prefix, Object[] objArray)
{
System.out.print(prefix);
- for (int i = 0; i < a.length; i++)
- System.out.print(a[i] + ":");
+ for (int i = 0; i < objArray.length; i++)
+ {
+ System.out.print(objArray[i] + ":");
+ }
System.out.println();
}
- public Class getGeneratedClass(String mGeneratedClassName)
+ /**
+ * Get a class for a generated class name.
+ *
+ *
+ * @param generatedClassName the generated class name
+ * @return the class
+ */
+ public Class getGeneratedClass(String generatedClassName)
{
- return getAltrmiClass(mGeneratedClassName);
+ return getAltrmiClass(generatedClassName);
}
/**
* Method getAltrmiClass.
* This get the Class definition from the bytes
- * @return Class
+ * @param className the clas name
+ * @return Class the class
*/
protected Class getAltrmiClass(String className)
{
1.11 +212 -187
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java
Index: ProxyGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ProxyGeneratorImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProxyGeneratorImpl.java 14 Jul 2002 23:12:44 -0000 1.10
+++ ProxyGeneratorImpl.java 15 Jul 2002 21:52:19 -0000 1.11
@@ -29,23 +29,23 @@
public class ProxyGeneratorImpl extends AbstractProxyGenerator
{
-
- protected PrintWriter mClassSource;
+ private PrintWriter m_classSource;
/**
* Method generate
*
*
- * @param cL
+ * @param classLoader the class loader to use.
+ * @throws ProxyGenerationException if a problem during generation.
*
*/
- public void generateSrc( ClassLoader cL ) throws ProxyGenerationException
+ public void generateSrc( ClassLoader classLoader ) throws
ProxyGenerationException
{
// The lookupable service class source.
- makeSource( cL, "Main", getInterfacesToExpose() );
- makeSource2( cL, "Main", getInterfacesToExpose() );
+ makeSource( classLoader, "Main", getInterfacesToExpose() );
+ makeSource2( classLoader, "Main", getInterfacesToExpose() );
if( getAdditionalFacades() != null )
{
@@ -53,8 +53,8 @@
{
Class facade = getAdditionalFacades()[ i ];
- makeSource( cL, encodeClassName( facade ), new Class[]{facade} );
- makeSource2( cL, encodeClassName( facade ), new Class[]{facade} );
+ makeSource( classLoader, encodeClassName( facade ), new
Class[]{facade} );
+ makeSource2( classLoader, encodeClassName( facade ), new
Class[]{facade} );
}
}
}
@@ -63,7 +63,7 @@
* Method generateClass
*
*
- * @param classLoader
+ * @param classLoader the class loader to use.
*
*/
public void generateClass( ClassLoader classLoader )
@@ -77,8 +77,10 @@
jc.addClassPath( getClassGenDir() );
jc.addClassPath( getClasspath() );
jc.addDefaultClassPath();
- jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated" +
getGenName() + "_Main.java" );
- jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated2" +
getGenName() + "_Main.java" );
+ jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated"
+ + getGenName() + "_Main.java" );
+ jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated2"
+ + getGenName() + "_Main.java" );
System.out.println( jc.getCompilerMessage() );
if( getAdditionalFacades() != null )
@@ -87,10 +89,10 @@
{
String classname = encodeClassName( getAdditionalFacades()[ i ] );
- jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated" +
getGenName() + "_"
- + classname + ".java" );
- jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated2"
+ getGenName() + "_"
- + classname + ".java" );
+ jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated"
+ + getGenName() + "_" + classname + ".java" );
+ jc.doCompile( getSrcGenDir() + File.separator + "AltrmiGenerated2"
+ + getGenName() + "_" + classname + ".java" );
}
}
}
@@ -118,25 +120,25 @@
* Method makeSource
*
*
- * @param cL
- * @param name
- * @param interfacesToExpose
+ * @param classloader the classloader to use
+ * @param name the name of the source file.
+ * @param interfacesToExpose the interfaces to expose.
*
- * @throws ProxyGenerationException
+ * @throws ProxyGenerationException if generation not possible.
*
*/
- public void makeSource( ClassLoader cL, String name, Class[] interfacesToExpose
)
+ public void makeSource( ClassLoader classloader, String name, Class[]
interfacesToExpose )
throws ProxyGenerationException
{
// methdos could be in more than one interface.
Vector methodsDone = new Vector();
- String filename = getSrcGenDir() + File.separator + "AltrmiGenerated" +
getGenName() + "_" + name
- + ".java";
+ String filename = getSrcGenDir() + File.separator + "AltrmiGenerated"
+ + getGenName() + "_" + name + ".java";
try
{
- mClassSource = new PrintWriter( new FileOutputStream( filename ) );
+ m_classSource = new PrintWriter( new FileOutputStream( filename ) );
}
catch( FileNotFoundException e )
{
@@ -144,26 +146,35 @@
+ "'" );
}
- mClassSource.print( "public class AltrmiGenerated" + getGenName() + "_" +
name );
- mClassSource.println( " implements
org.apache.excalibur.altrmi.client.AltrmiProxy{ " );
- mClassSource.println(
+ m_classSource.print( "public class AltrmiGenerated" + getGenName() + "_" +
name );
+ m_classSource.println( " implements
org.apache.excalibur.altrmi.client.AltrmiProxy{ " );
+ m_classSource.println(
" private transient org.apache.excalibur.altrmi.client.ProxyHelper
mProxyHelper;" );
// Generate Constructor
- mClassSource.println(
+ m_classSource.println(
" public AltrmiGenerated" + getGenName() + "_" + name
+ " (org.apache.excalibur.altrmi.client.ProxyHelper proxyHelper) {" );
- mClassSource.println( " mProxyHelper = proxyHelper;" );
- mClassSource.println( " }" );
+ m_classSource.println( " mProxyHelper = proxyHelper;" );
+ m_classSource.println( " }" );
// helper method for the factory.
// from AltrmiProxy interface
- mClassSource
+ m_classSource
.println( " public Long altrmiGetReferenceID(Object
factoryThatIsAsking) {" );
- mClassSource
+ m_classSource
.println( " return
mProxyHelper.getReferenceID(factoryThatIsAsking);" );
- mClassSource.println( " }" );
+ m_classSource.println( " }" );
+
+ makeSourceInterfaces(interfacesToExpose, methodsDone);
+
+ m_classSource.print( "}" );
+ m_classSource.close();
+ }
+ private void makeSourceInterfaces(Class[] interfacesToExpose,
+ Vector methodsDone) throws ProxyGenerationException
+ {
// TODO DefaultProxyHelper altrmiGetProxyHelper();
for( int x = 0; x < interfacesToExpose.length; x++ )
{
@@ -188,134 +199,146 @@
if( !methodsDone.contains( methodSignature ) )
{
- methodsDone.add( methodSignature );
-
- Class rClass = method.getReturnType();
+ makeSourceInterfacesMethodsNotDone(methodsDone,
methodSignature, method);
- if( !( method.getReturnType() instanceof Serializable ) )
- {
- throw new ProxyGenerationException( "Return type " + rClass
- + " must be
serializable" );
- }
-
- String mName = method.getName();
-
- mClassSource.print( " public " + generateReturnValue( rClass )
+ " " + mName
- + " (" );
-
- Class[] argTypes = method.getParameterTypes();
-
- for( int i = 0; i < argTypes.length; i++ )
- {
- String cn = ( argTypes[ i ].isArray()
- ? argTypes[ i ].getComponentType().getName()
- : argTypes[ i ].getName() );
-
- if( !( argTypes[ i ] instanceof Serializable ) )
- {
- throw new ProxyGenerationException( "Argument type " +
cn
- + " must be
serializable" );
- }
-
- generateParameter( argTypes[ i ], i );
- }
-
- mClassSource.print( ") " );
-
- Class[] throwsTypes = method.getExceptionTypes();
-
- for( int i = 0; i < throwsTypes.length; i++ )
- {
- generateThrows( i, throwsTypes );
- }
-
- mClassSource.println( "{" );
- mClassSource.println( " Object[] args = new Object[" +
argTypes.length
- + "];" );
- mClassSource.println( " Class[] argClasses = new Class[" +
argTypes.length
- + "];" );
-
- for( int i = 0; i < argTypes.length; i++ )
- {
- generateAssignLine( argTypes[ i ], i );
- }
-
- mClassSource.println( " try {" );
-
- if( rClass.equals( "void" ) )
- {
- mClassSource.println( "
mProxyHelper.processVoidRequest(\""
- + methodSignature.toString() +
"\",args);" );
- }
- else
- {
- boolean isFacadeRetVal = isAdditionalFacade(
method.getReturnType() );
-
- if( isFacadeRetVal )
- {
- Class retClassType = rClass;
- if( rClass.isArray() )
- {
- retClassType = rClass.getComponentType();
- }
-
- mClassSource.println(
- " Object retVal =
mProxyHelper.processObjectRequestGettingFacade("
- + retClassType.getName() + ".class , \""
- + methodSignature.toString() + "\",args,\""
- + encodeClassName( getClassType( rClass ) ) +
"\");" );
- mClassSource.println( " return (" + getClassType(
rClass )
- + ") retVal;" );
- }
- else
- {
- mClassSource.println(
- " Object retVal =
mProxyHelper.processObjectRequest(\""
- + methodSignature.toString() +
"\",args,argClasses);" );
- generateReturnLine( rClass );
- }
- }
-
- mClassSource.println( " } catch (Throwable t) {" );
-
- throwsTypes = method.getExceptionTypes();
-
- for( int i = 0; i < throwsTypes.length; i++ )
- {
- generateThrowHandler( i, throwsTypes );
- }
-
- mClassSource.println( " if (t instanceof RuntimeException)
{ " );
- mClassSource.println( " throw (RuntimeException) t;" );
- mClassSource.println( " } else if (t instanceof Error) { "
);
- mClassSource.println( " throw (Error) t;" );
- mClassSource.println( " } else { " );
- mClassSource.println( " t.printStackTrace(); " );
- mClassSource.println(
- " throw new
org.apache.excalibur.altrmi.common.AltrmiInvocationException(\"Should never get here:
\" + t.getMessage()); " );
- mClassSource.println( " }" );
- mClassSource.println( " }" );
- mClassSource.println( " }" );
}
}
}
+ }
+
+ private void makeSourceInterfacesMethodsNotDone(Vector methodsDone,
+ String methodSignature, Method method) throws ProxyGenerationException
+ {
+ methodsDone.add( methodSignature );
+
+ Class rClass = method.getReturnType();
+
+ if( !( method.getReturnType() instanceof Serializable ) )
+ {
+ throw new ProxyGenerationException( "Return type " + rClass
+ + " must be serializable" );
+ }
+
+ String mName = method.getName();
+
+ m_classSource.print( " public " + generateReturnValue( rClass ) + " " +
mName
+ + " (" );
+
+ Class[] argTypes = method.getParameterTypes();
+
+ for( int i = 0; i < argTypes.length; i++ )
+ {
+ String cn = ( argTypes[ i ].isArray()
+ ? argTypes[ i ].getComponentType().getName()
+ : argTypes[ i ].getName() );
+
+ if( !( argTypes[ i ] instanceof Serializable ) )
+ {
+ throw new ProxyGenerationException( "Argument type " + cn
+ + " must be serializable" );
+ }
+
+ generateParameter( argTypes[ i ], i );
+ }
+
+ m_classSource.print( ") " );
+
+ Class[] throwsTypes = method.getExceptionTypes();
+
+ for( int i = 0; i < throwsTypes.length; i++ )
+ {
+ generateThrows( i, throwsTypes );
+ }
+
+ m_classSource.println( "{" );
+ m_classSource.println( " Object[] args = new Object[" + argTypes.length
+ + "];" );
+ m_classSource.println( " Class[] argClasses = new Class[" +
argTypes.length
+ + "];" );
- mClassSource.print( "}" );
- mClassSource.close();
+ for( int i = 0; i < argTypes.length; i++ )
+ {
+ generateAssignLine( argTypes[ i ], i );
+ }
+
+ m_classSource.println( " try {" );
+
+ if( rClass.equals( "void" ) )
+ {
+ m_classSource.println( " mProxyHelper.processVoidRequest(\""
+ + methodSignature.toString() + "\",args);" );
+ }
+ else
+ {
+ makeSourceInterfacesMethodsNotDoneNotVoid(method, rClass,
methodSignature);
+
+ }
+
+ m_classSource.println( " } catch (Throwable t) {" );
+
+ throwsTypes = method.getExceptionTypes();
+
+ for( int i = 0; i < throwsTypes.length; i++ )
+ {
+ generateThrowHandler( i, throwsTypes );
+ }
+
+ m_classSource.println( " if (t instanceof RuntimeException) { " );
+ m_classSource.println( " throw (RuntimeException) t;" );
+ m_classSource.println( " } else if (t instanceof Error) { " );
+ m_classSource.println( " throw (Error) t;" );
+ m_classSource.println( " } else { " );
+ m_classSource.println( " t.printStackTrace(); " );
+ m_classSource.println(
+ " throw new org.apache.excalibur.altrmi.common."+
+ "AltrmiInvocationException(\"Should never get here: \"
+t.getMessage());");
+ m_classSource.println( " }" );
+ m_classSource.println( " }" );
+ m_classSource.println( " }" );
+ }
+
+ private void makeSourceInterfacesMethodsNotDoneNotVoid(Method method,
+ Class rClass, String methodSignature)
+ {
+ boolean isFacadeRetVal = isAdditionalFacade( method.getReturnType() );
+
+ if( isFacadeRetVal )
+ {
+ Class retClassType = rClass;
+ if( rClass.isArray() )
+ {
+ retClassType = rClass.getComponentType();
+ }
+
+ m_classSource.println(
+ " Object retVal = mProxyHelper.processObjectRequestGettingFacade("
+ + retClassType.getName() + ".class , \""
+ + methodSignature.toString() + "\",args,\""
+ + encodeClassName( getClassType( rClass ) ) + "\");" );
+ m_classSource.println( " return (" + getClassType( rClass )
+ + ") retVal;" );
+ }
+ else
+ {
+ m_classSource.println(
+ " Object retVal = mProxyHelper.processObjectRequest(\""
+ + methodSignature.toString() + "\",args,argClasses);" );
+ generateReturnLine( rClass );
+ }
}
/**
* Method makeSource2
*
*
- * @param cL
- * @param name
- * @param interfacesToExpose
+ * @param classloader the classloader to use
+ * @param name the name of the source file.
+ * @param interfacesToExpose the interfaces to expose.
*
- * @throws ProxyGenerationException
+ * @throws ProxyGenerationException if generation not possible.
*
*/
- public void makeSource2( ClassLoader cL, String name, Class[]
interfacesToExpose )
+ public void makeSource2( ClassLoader classloader, String name, Class[]
interfacesToExpose )
throws ProxyGenerationException
{
@@ -351,19 +374,20 @@
if( i == 0 )
{
- mClassSource.println( " if (t instanceof " + throwsTypes[ i
].getName() + ") { " );
+ m_classSource.println(
+ " if (t instanceof " + throwsTypes[ i ].getName() + ") { "
);
}
else
{
- mClassSource.println( " } else if (t instanceof " + throwsTypes[ i
].getName()
+ m_classSource.println( " } else if (t instanceof " + throwsTypes[
i ].getName()
+ ") { " );
}
- mClassSource.println( " throw (" + throwsTypes[ i ].getName() + ")
t;" );
+ m_classSource.println( " throw (" + throwsTypes[ i ].getName() + ")
t;" );
if( i + 1 == throwsTypes.length )
{
- mClassSource.print( " } else" );
+ m_classSource.print( " } else" );
}
}
@@ -372,14 +396,14 @@
if( i == 0 )
{
- mClassSource.print( "throws " );
+ m_classSource.print( "throws " );
}
- mClassSource.print( throwsTypes[ i ].getName() );
+ m_classSource.print( throwsTypes[ i ].getName() );
if( i + 1 < throwsTypes.length )
{
- mClassSource.print( ", " );
+ m_classSource.print( ", " );
}
}
@@ -402,19 +426,19 @@
if( i > 0 )
{
- mClassSource.print( ", " );
+ m_classSource.print( ", " );
}
if( cl.isArray() )
{
- mClassSource.print( cl.getComponentType().getName() + "[]" );
+ m_classSource.print( cl.getComponentType().getName() + "[]" );
}
else
{
- mClassSource.print( cl.getName() );
+ m_classSource.print( cl.getName() );
}
- mClassSource.print( " v" + i );
+ m_classSource.print( " v" + i );
}
private void generateAssignLine( Class clazz, int i )
@@ -424,40 +448,41 @@
if( cn.equals( "int" ) )
{
- mClassSource.println( " args[" + i + "] = new Integer(v" + i + ");"
);
+ m_classSource.println( " args[" + i + "] = new Integer(v" + i + ");"
);
}
else if( cn.equals( "short" ) )
{
- mClassSource.println( " args[" + i + "] = new Short(v" + i + ");" );
+ m_classSource.println( " args[" + i + "] = new Short(v" + i + ");" );
}
else if( cn.equals( "float" ) )
{
- mClassSource.println( " args[" + i + "] = new Float(v" + i + ");" );
+ m_classSource.println( " args[" + i + "] = new Float(v" + i + ");" );
}
else if( cn.equals( "double" ) )
{
- mClassSource.println( " args[" + i + "] = new Double(v" + i + ");" );
+ m_classSource.println( " args[" + i + "] = new Double(v" + i + ");"
);
}
else if( cn.equals( "long" ) )
{
- mClassSource.println( " args[" + i + "] = new Long(v" + i + ");" );
+ m_classSource.println( " args[" + i + "] = new Long(v" + i + ");" );
}
else if( cn.equals( "char" ) )
{
- mClassSource.println( " args[" + i + "] = new Character(v" + i +
");" );
+ m_classSource.println( " args[" + i + "] = new Character(v" + i +
");" );
}
else if( cn.equals( "boolean" ) )
{
- mClassSource.println( " args[" + i + "] = new Boolean(v" + i + ");"
);
+ m_classSource.println( " args[" + i + "] = new Boolean(v" + i + ");"
);
}
else if( cn.equals( "byte" ) )
{
- mClassSource.println( " args[" + i + "] = new Byte(v" + i + ");" );
+ m_classSource.println( " args[" + i + "] = new Byte(v" + i + ");" );
}
else
{
- mClassSource.println( " args[" + i + "] = v" + i + ";" );
- mClassSource.println( " argClasses[" + i + "] = " +
generateReturnValue( clazz ) + ".class;" );
+ m_classSource.println( " args[" + i + "] = v" + i + ";" );
+ m_classSource.println( " argClasses[" + i + "] = "
+ + generateReturnValue( clazz ) + ".class;" );
}
}
@@ -468,80 +493,80 @@
if( cn.equals( "boolean" ) )
{
- mClassSource.println( " return ((Boolean) retVal).booleanValue();"
);
+ m_classSource.println( " return ((Boolean)
retVal).booleanValue();" );
}
else if( cn.equals( "int" ) )
{
- mClassSource.println( " return ((Integer) retVal).intValue();" );
+ m_classSource.println( " return ((Integer) retVal).intValue();" );
}
else if( cn.equals( "short" ) )
{
- mClassSource.println( " return ((Short) retVal).shortValue();" );
+ m_classSource.println( " return ((Short) retVal).shortValue();" );
}
else if( cn.equals( "float" ) )
{
- mClassSource.println( " return ((Float) retVal).floatValue();" );
+ m_classSource.println( " return ((Float) retVal).floatValue();" );
}
else if( cn.equals( "double" ) )
{
- mClassSource.println( " return ((Double) retVal).doubleValue();" );
+ m_classSource.println( " return ((Double) retVal).doubleValue();"
);
}
else if( cn.equals( "long" ) )
{
- mClassSource.println( " return ((Long) retVal).longValue();" );
+ m_classSource.println( " return ((Long) retVal).longValue();" );
}
else if( cn.equals( "char" ) )
{
- mClassSource.println( " return ((Character) retVal).charValue();"
);
+ m_classSource.println( " return ((Character) retVal).charValue();"
);
}
else if( cn.equals( "void" ) )
{
- mClassSource.println( " return;" );
+ m_classSource.println( " return;" );
}
else if( cn.equals( "byte" ) )
{
- mClassSource.println( " return ((Byte) retVal).byteValue();" );
+ m_classSource.println( " return ((Byte) retVal).byteValue();" );
}
else if( cn.equals( "[B" ) )
{
- mClassSource.println( " return (byte[]) retVal;" );
+ m_classSource.println( " return (byte[]) retVal;" );
}
else if( cn.equals( "[C" ) )
{
- mClassSource.println( " return (char[]) retVal;" );
+ m_classSource.println( " return (char[]) retVal;" );
}
else if( cn.equals( "[D" ) )
{
- mClassSource.println( " return (double[]) retVal;" );
+ m_classSource.println( " return (double[]) retVal;" );
}
else if( cn.equals( "[F" ) )
{
- mClassSource.println( " return (float[]) retVal;" );
+ m_classSource.println( " return (float[]) retVal;" );
}
else if( cn.equals( "[I" ) )
{
- mClassSource.println( " return (int[]) retVal;" );
+ m_classSource.println( " return (int[]) retVal;" );
}
else if( cn.equals( "[J" ) )
{
- mClassSource.println( " return (long[]) retVal;" );
+ m_classSource.println( " return (long[]) retVal;" );
}
else if( cn.equals( "[S" ) )
{
- mClassSource.println( " return (short[]) retVal;" );
+ m_classSource.println( " return (short[]) retVal;" );
}
else if( cn.equals( "[Z" ) )
{
- mClassSource.println( " return (boolean[]) retVal;" );
+ m_classSource.println( " return (boolean[]) retVal;" );
}
else if( rClass.getName().startsWith( "[L" ) )
{
- mClassSource.println( " return (" + cn.substring( 2, cn.length() -
1 )
+ m_classSource.println( " return (" + cn.substring( 2, cn.length()
- 1 )
+ "[]) retVal;" );
}
else
{
- mClassSource.println( " return (" + cn + ") retVal;" );
+ m_classSource.println( " return (" + cn + ") retVal;" );
}
}
1.7 +9 -9
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ant/AltrmiProxyTask.java
Index: AltrmiProxyTask.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/generator/ant/AltrmiProxyTask.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AltrmiProxyTask.java 23 May 2002 21:37:21 -0000 1.6
+++ AltrmiProxyTask.java 15 Jul 2002 21:52:19 -0000 1.7
@@ -255,13 +255,13 @@
proxyGenerator.setClasspath( mClasspath.concatSystemClasspath( "ignore"
).toString() );
Class[] interfacesToExpose = new Class[ mInterfacesToExpose.length ];
- ClassLoader cLoader = new AntClassLoader( getProject(), mClasspath );
+ ClassLoader classLoader = new AntClassLoader( getProject(), mClasspath
);
for( int i = 0; i < mInterfacesToExpose.length; i++ )
{
String cn = mInterfacesToExpose[ i ];
- interfacesToExpose[ i ] = cLoader.loadClass( cn );
+ interfacesToExpose[ i ] = classLoader.loadClass( cn );
}
proxyGenerator.setInterfacesToExpose( interfacesToExpose );
@@ -274,25 +274,25 @@
{
String cn = mAdditionalFacades[ i ];
- additionalFacades[ i ] = cLoader.loadClass( cn );
+ additionalFacades[ i ] = classLoader.loadClass( cn );
}
proxyGenerator.setAdditionalFacades( additionalFacades );
}
- ClassLoader cL = null;
+ ClassLoader classLoader2 = null;
if( mClasspath != null )
{
- cL = new AntClassLoader( project, mClasspath );
+ classLoader2 = new AntClassLoader( project, mClasspath );
}
else
{
- cL = this.getClass().getClassLoader();
+ classLoader2 = this.getClass().getClassLoader();
}
- proxyGenerator.generateSrc( cL );
- proxyGenerator.generateClass( cL );
+ proxyGenerator.generateSrc( classLoader2 );
+ proxyGenerator.generateClass( classLoader2 );
}
catch( ClassNotFoundException cnfe )
{
1.4 +23 -7
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/AbstractClassRetriever.java
Index: AbstractClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/AbstractClassRetriever.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractClassRetriever.java 14 Jul 2002 23:12:44 -0000 1.3
+++ AbstractClassRetriever.java 15 Jul 2002 21:52:19 -0000 1.4
@@ -25,6 +25,11 @@
private ClassLoader m_classLoader;
+ /**
+ * Set the classloader to use.
+ *
+ * @param classLoader the classloader to use.
+ */
protected void setClassLoader( ClassLoader classLoader )
{
m_classLoader = classLoader;
@@ -34,11 +39,11 @@
* Method getBeanBytes
*
*
- * @param publishedName
+ * @param publishedName the publication name
*
- * @return
+ * @return a byte array for the Bean.
*
- * @throws ClassRetrievalException
+ * @throws ClassRetrievalException if the bytes cannot be retrieved.
*
*/
public final byte[] getBeanBytes( String publishedName ) throws
ClassRetrievalException
@@ -50,11 +55,11 @@
* Method getInterfaceImplementationBytes
*
*
- * @param publishedName
+ * @param publishedName the publication name
*
- * @return
+ * @return a byte array for the Bean.
*
- * @throws ClassRetrievalException
+ * @throws ClassRetrievalException if the bytes cannot be retrieved.
*
*/
public final byte[] getInterfaceImplementationBytes( String publishedName )
@@ -63,6 +68,17 @@
return getThingBytes( "AltrmiGenerated2" + publishedName );
}
+ /**
+ * Method getThingBytes
+ *
+ *
+ * @param thingName the publication name
+ *
+ * @return a byte array for the thing.
+ *
+ * @throws ClassRetrievalException if the bytes cannot be retrieved.
+ *
+ */
protected byte[] getThingBytes( String thingName ) throws
ClassRetrievalException
{
1.2 +37 -29
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/AbstractDynamicGeneratorClassRetriever.java
Index: AbstractDynamicGeneratorClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/AbstractDynamicGeneratorClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractDynamicGeneratorClassRetriever.java 14 Jul 2002 23:12:44 -0000
1.1
+++ AbstractDynamicGeneratorClassRetriever.java 15 Jul 2002 21:52:19 -0000
1.2
@@ -37,9 +37,9 @@
private Class m_generatorClass ;
/**
- * Constructor AbstractDynamicGeneratorClassRetriever
- *
*
+ * @param genJarURL the user of the generated jar file
+ * @param generatorClass the class to use for generation.
*/
public AbstractDynamicGeneratorClassRetriever( URL genJarURL, Class
generatorClass)
{
@@ -51,26 +51,28 @@
* Method generate
*
*
- * @param asName
- * @param interfaceToExpose
- * @param classLoader
+ * @param asName the name to generate as
+ * @param interfaceToExpose the interfaces to expose.
+ * @param classLoader the classloader to use during generation.
+ * @throws PublicationException if the generation failed.
*
*/
public void generate( String asName, Class interfaceToExpose, ClassLoader
classLoader )
throws PublicationException
{
- generateProxy( asName, new PublicationDescription( interfaceToExpose ),
classLoader, false );
+ generateProxy( asName, new PublicationDescription( interfaceToExpose ),
+ classLoader, false );
}
/**
* Method generate
*
*
- * @param asName
- * @param publicationDescription
- * @param classLoader
+ * @param asName the name to generate as
+ * @param publicationDescription the description of the publication
+ * @param classLoader the class loader to use.
*
- * @throws PublicationException
+ * @throws PublicationException if the generation failed.
*
*/
public void generate(
@@ -84,11 +86,11 @@
* Method deferredGenerate
*
*
- * @param asName
- * @param publicationDescription
- * @param classLoader
+ * @param asName the name of the clas to generate
+ * @param publicationDescription the description of the publication
+ * @param classLoader the class loader to use.
*
- * @throws PublicationException
+ * @throws PublicationException if the generation failed.
*
*/
public void deferredGenerate(
@@ -99,10 +101,10 @@
}
/**
- * Method setAltrmiClasspath
+ * Use this classpath during retrieval.
*
*
- * @param altrmiClasspath
+ * @param altrmiClasspath the classpath
*
*/
public void setAltrmiClasspath( String altrmiClasspath )
@@ -114,7 +116,7 @@
* Method addToAltrmiClasspath
*
*
- * @param classpathElement
+ * @param classpathElement an element for the classpath
*
*/
public void addToAltrmiClasspath( String classpathElement )
@@ -126,7 +128,7 @@
* Method setClassGenDir
*
*
- * @param classGenDir
+ * @param classGenDir the class generation directory
*
*/
public void setClassGenDir( String classGenDir )
@@ -138,11 +140,11 @@
* Method getBeanBytes
*
*
- * @param publishedName
+ * @param publishedName the name to publish as
*
- * @return
+ * @return the byte array for the bean.
*
- * @throws ClassRetrievalException
+ * @throws ClassRetrievalException if the class cannot be retrieved.
*
*/
public final byte[] getBeanBytes( String publishedName ) throws
ClassRetrievalException
@@ -154,11 +156,11 @@
* Method getInterfaceImplementationBytes
*
*
- * @param publishedName
+ * @param publishedName the name to publish as
*
- * @return
+ * @return the byte array for the bean.
*
- * @throws ClassRetrievalException
+ * @throws ClassRetrievalException if the class cannot be retrieved.
*
*/
public final byte[] getInterfaceImplementationBytes( String publishedName )
@@ -167,6 +169,12 @@
return getThingBytes( "AltrmiGenerated2" + publishedName );
}
+ /**
+ *
+ * @param thingName the thing name
+ * @return the byte array of the thing.
+ * @throws ClassRetrievalException if getting the bytes was a problem.
+ */
protected byte[] getThingBytes( String thingName ) throws
ClassRetrievalException
{
@@ -221,7 +229,7 @@
* Method setSrcGenDir
*
*
- * @param srcGenDir
+ * @param srcGenDir the source generaton directory.
*
*/
public void setSrcGenDir( String srcGenDir )
@@ -230,7 +238,8 @@
}
private void generateProxy(
- String asName, PublicationDescription publicationDescription, ClassLoader
classLoader, boolean deferred )
+ String asName, PublicationDescription publicationDescription,
+ ClassLoader classLoader, boolean deferred )
throws PublicationException
{
@@ -267,7 +276,6 @@
proxyGenerator.setInterfacesToExpose( interfacesToExpose );
proxyGenerator.setAdditionalFacades( addInfs );
- //ClassLoader cL = this.getClass().getClassLoader();
try
{
proxyGenerator.generateSrc( classLoader );
@@ -343,7 +351,7 @@
* Method generateDeferred
*
*
- * @param classLoader
+ * @param classLoader the classloader to use.
*
*/
public void generateDeferred( ClassLoader classLoader )
1.2 +7 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/BcelDynamicGeneratorClassRetriever.java
Index: BcelDynamicGeneratorClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/BcelDynamicGeneratorClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BcelDynamicGeneratorClassRetriever.java 14 Jul 2002 23:12:44 -0000 1.1
+++ BcelDynamicGeneratorClassRetriever.java 15 Jul 2002 21:52:19 -0000 1.2
@@ -21,6 +21,12 @@
*/
public class BcelDynamicGeneratorClassRetriever extends
AbstractDynamicGeneratorClassRetriever
{
+ /**
+ * Contruct a Dynamic Class Generator with a URL for the generated Jar File.
+ *
+ * @param genJarURL a URL for the generated Jar File
+ */
+
public BcelDynamicGeneratorClassRetriever(URL genJarURL)
{
super(genJarURL, BCELProxyGeneratorImpl.class);
1.3 +11 -11
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JarFileClassRetriever.java
Index: JarFileClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JarFileClassRetriever.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JarFileClassRetriever.java 24 Apr 2002 12:43:02 -0000 1.2
+++ JarFileClassRetriever.java 15 Jul 2002 21:52:19 -0000 1.3
@@ -23,10 +23,10 @@
{
/**
- * Constructor JarFileClassRetriever
+ * Contruct a ClassRetriever from url of a JAR file.
*
*
- * @param urlOfJarFile
+ * @param urlOfJarFile the jar file URL.
*
*/
public JarFileClassRetriever( URL urlOfJarFile )
@@ -35,10 +35,10 @@
}
/**
- * Constructor JarFileClassRetriever
+ * Contruct a ClassRetriever from urls of JAR files.
*
*
- * @param urlsOfJarFiles
+ * @param urlsOfJarFiles the jar file URLs.
*
*/
public JarFileClassRetriever( URL[] urlsOfJarFiles )
@@ -47,12 +47,12 @@
}
/**
- * Constructor JarFileClassRetriever
+ * Contruct a ClassRetriever from file paths.
*
*
- * @param pathsOfJarFiles
+ * @param pathsOfJarFiles the paths that map to URLs
*
- * @throws MalformedURLException
+ * @throws MalformedURLException if the paths are not mappable to URLS.
*
*/
public JarFileClassRetriever( String[] pathsOfJarFiles ) throws
MalformedURLException
@@ -69,12 +69,12 @@
}
/**
- * Constructor JarFileClassRetriever
+ * Construct from a path to a jar file
*
*
- * @param pathOfJarFile
+ * @param pathOfJarFile the path
*
- * @throws MalformedURLException
+ * @throws MalformedURLException if the path is not mappable to a URL.
*
*/
public JarFileClassRetriever( String pathOfJarFile ) throws
MalformedURLException
1.2 +5 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JavacDynamicGeneratorClassRetriever.java
Index: JavacDynamicGeneratorClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/JavacDynamicGeneratorClassRetriever.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JavacDynamicGeneratorClassRetriever.java 14 Jul 2002 23:12:44 -0000 1.1
+++ JavacDynamicGeneratorClassRetriever.java 15 Jul 2002 21:52:19 -0000 1.2
@@ -21,6 +21,10 @@
*/
public class JavacDynamicGeneratorClassRetriever extends
AbstractDynamicGeneratorClassRetriever
{
+ /**
+ *
+ * @param genJarURL the url of the generated jar file.
+ */
public JavacDynamicGeneratorClassRetriever(URL genJarURL)
{
super(genJarURL, ProxyGeneratorImpl.class);
1.3 +7 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/NoClassRetriever.java
Index: NoClassRetriever.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/classretrievers/NoClassRetriever.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NoClassRetriever.java 24 Apr 2002 12:43:02 -0000 1.2
+++ NoClassRetriever.java 15 Jul 2002 21:52:19 -0000 1.3
@@ -19,6 +19,12 @@
public class NoClassRetriever extends AbstractClassRetriever
{
+ /**
+ *
+ * @param thingName get a byte array for a thing.
+ * @return the byte array
+ * @throws ClassRetrievalException if the retrieval failed.
+ */
protected byte[] getThingBytes( String thingName ) throws
ClassRetrievalException
{
throw new ClassRetrievalException( "This AltRMI server does not support
class forwarding" );
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>