|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.objectweb.fractal.rmi.ClassGeneratorImpl
public class ClassGeneratorImpl
| Field Summary | |
|---|---|
protected java.lang.ClassLoader |
cl
A class loader used by this component to load classes |
protected org.objectweb.util.monolog.api.Logger |
logger
The logger used to log messages. |
| Fields inherited from interface org.objectweb.asm.Opcodes |
|---|
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, V1_1, V1_2, V1_3, V1_4, V1_5 |
| Constructor Summary | |
|---|---|
ClassGeneratorImpl()
|
|
| Method Summary | |
|---|---|
java.lang.Class |
generateClass(java.lang.String className)
Generates a skeleton or a stub Class for a class of a given name. |
java.lang.Class |
generateClass(java.lang.String className,
java.lang.ClassLoader cl)
Generates a skeleton or a stub Class for a class of a given name. |
protected void |
generateConstructor(org.objectweb.asm.ClassVisitor cv,
java.lang.String superClass)
Generates an empty constructor for the given class. |
protected void |
generateSkeletonClass(org.objectweb.asm.ClassVisitor cv,
java.lang.Class itf)
Generates a skeleton class for the given Java interface. |
protected void |
generateSkeletonMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String name,
java.lang.Class itf)
Generates a skeleton's send method. |
protected void |
generateStubClass(org.objectweb.asm.ClassVisitor cv,
java.lang.Class itf)
Generates a stub class for the given Java interface. |
protected void |
generateStubMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String name,
java.lang.reflect.Method m,
int index)
Generates a stub method. |
java.lang.ClassLoader |
getFcClassLoader()
Returns a class loader used by this component |
protected boolean |
isClassParameter(java.lang.reflect.Method m,
int p)
Returns true if the specified parameter contains the name of a class. |
java.lang.Class |
loadClass(java.lang.String className)
Loads a class of a given name |
void |
setFcClassLoader(java.lang.ClassLoader cl)
Sets the class loader used by this component |
protected static void |
sort(java.lang.reflect.Method[] methods)
Sorts the given methods. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.objectweb.util.monolog.api.Logger logger
protected java.lang.ClassLoader cl
| Constructor Detail |
|---|
public ClassGeneratorImpl()
| Method Detail |
|---|
public java.lang.Class loadClass(java.lang.String className)
throws java.lang.ClassNotFoundException
ClassGenerator
loadClass in interface ClassGeneratorclassName - name of the class to be loaded
java.lang.ClassNotFoundException
public java.lang.Class generateClass(java.lang.String className,
java.lang.ClassLoader cl)
ClassGenerator
generateClass in interface ClassGeneratorclassName - name of the class for which a stub or a skeleton is to be generatedcl - a class loader to be used to generate the stub/skeleton
public java.lang.Class generateClass(java.lang.String className)
ClassGenerator
generateClass in interface ClassGeneratorclassName - name of the class for which a stub or a skeleton is to be generated
protected void generateStubClass(org.objectweb.asm.ClassVisitor cv,
java.lang.Class itf)
Stub class that implements the given
interface, by using the given class visitor.
cv - the class visitor to be used to generate the stub class.itf - the Java interface that the stub class must implement.
protected void generateSkeletonClass(org.objectweb.asm.ClassVisitor cv,
java.lang.Class itf)
Skeleton class whose target is an object implementing the given interface, by
using the given class visitor.
cv - the class visitor to be used to generate the stub class.itf - the Java interface implemented by the skeleton's target.
protected void generateConstructor(org.objectweb.asm.ClassVisitor cv,
java.lang.String superClass)
cv - the class visitor to be used to generate the constructor.superClass - the internal name of the super class of the generated class.
This name is used to generate a call to the super constructor.
protected void generateStubMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String name,
java.lang.reflect.Method m,
int index)
public <i>T</i> m (<i>T0 arg0</i>, ...) throws <i>E0</i>, ... {
try {
Marshaller marshaller = request();
ReplyInterface reply = prepareInvocation(marshaller);
marshaller.writeInt(<i>methodIndex</i>);
marshaller.write<i>XXX</i>(<i>arg0</i>);
...
invoke(marshaller);
UnMarshaller unmarshaller = reply.listen();
<i>T</i> result = (<i>T</i>)unmarshaller.read<i>XXX</i>();
unmarshaller.close();
return result;
} catch (Exception e) {
e = handleException(e);
if (e instanceof <i>E0</i>) throw (<i>E0</i>)e;
...
if (e instanceof RuntimeException) throw (RuntimeException)e;
throw new RemoteException("server side exception", e);
}
}
cv - the class visitor to be used to generate the stub method.name - the internal name of the generated stub class.m - the signature of the method that must be generated.index - the index of this method. This index will be marshalled by the
generated stub method in each invocation message, to specify
the method that must be called on the server side. This index
is the index of the method in the sorted array
of all the methods implemented by the stub.
protected void generateSkeletonMethod(org.objectweb.asm.ClassVisitor cv,
java.lang.String name,
java.lang.Class itf)
send method. The generated
method is of the following form:
public void send (UnMarshaller unmarshaller, ReplySession session)
throws JonathanException
{
int methodIndex = unmarshaller.readInt();
try {
switch (methodIndex) {
case 0:
<i>T0 arg0</i> = unmarshaller.read<i>XXX</i>();
...
unmarshaller.close();
<i>T</i> result = ((<i>I</i>)target).<i>m0</i>(<i>arg0</i>, ... );
Marshaller marshaller = session.prepareReply();
marshaller.write<i>XXX</i>(result);
session.send(marshaller);
session.close();
return;
...
default:
handleInterfaceMethods(unmarshaller, session, methodIndex);
}
} catch (Exception e) {
handleException(e, session);
}
}
cv - the class visitor to be used to generate the stub method.name - the internal name of the generated stub class.itf - the target object's interface that must be exported by the
skeleton.
protected boolean isClassParameter(java.lang.reflect.Method m,
int p)
m - a method.p - index of a parameter of this method, or -1 to
designate the return value.
protected static void sort(java.lang.reflect.Method[] methods)
getMethods cannot directly be used
for this purpose, since this method returns the methods in any order).
methods - the method array to be sorted.public java.lang.ClassLoader getFcClassLoader()
ClassLoaderController
getFcClassLoader in interface ClassLoaderControllerpublic void setFcClassLoader(java.lang.ClassLoader cl)
ClassLoaderController
setFcClassLoader in interface ClassLoaderControllercl - a class loader to be used by this component
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||