public class StubGenerator extends java.lang.Object implements Translator
The proxy class for class A is as follows:
public class A implements Proxy, Serializable {
private ObjectImporter importer;
private int objectId;
public int _getObjectId() { return objectId; }
public A(ObjectImporter oi, int id) {
importer = oi; objectId = id;
}
... the same methods that the original class A declares ...
}
Instances of the proxy class is created by an
ObjectImporter object.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
accessorObjectId |
private ClassPool |
classPool |
private CtClass[] |
exceptionForProxy |
private static java.lang.String |
fieldImporter |
private static java.lang.String |
fieldObjectId |
private CtMethod |
forwardMethod |
private CtMethod |
forwardStaticMethod |
private CtClass[] |
interfacesForProxy |
private java.util.Hashtable |
proxyClasses |
private CtClass[] |
proxyConstructorParamTypes |
private static java.lang.String |
sampleClass |
| Constructor and Description |
|---|
StubGenerator()
Constructs a stub-code generator.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addMethods(CtClass proxy,
java.lang.reflect.Method[] ms) |
boolean |
isProxyClass(java.lang.String name)
Returns
true if the specified class is a proxy class
recorded by makeProxyClass(). |
boolean |
makeProxyClass(java.lang.Class clazz)
Makes a proxy class.
|
private void |
modifySuperclass(CtClass orgclass)
Adds a default constructor to the super classes.
|
void |
onLoad(ClassPool pool,
java.lang.String classname)
Does nothing.
|
private CtClass |
produceProxyClass(CtClass orgclass,
java.lang.Class orgRtClass) |
void |
start(ClassPool pool)
Initializes the object.
|
private CtClass |
toCtClass(java.lang.Class rtclass) |
private CtClass[] |
toCtClass(java.lang.Class[] rtclasses) |
private static final java.lang.String fieldImporter
private static final java.lang.String fieldObjectId
private static final java.lang.String accessorObjectId
private static final java.lang.String sampleClass
private ClassPool classPool
private java.util.Hashtable proxyClasses
private CtMethod forwardMethod
private CtMethod forwardStaticMethod
private CtClass[] proxyConstructorParamTypes
private CtClass[] interfacesForProxy
private CtClass[] exceptionForProxy
public void start(ClassPool pool) throws NotFoundException
start in interface Translatorpool - the ClassPool that this translator
should use.NotFoundException - if a CtClass cannot be found.Translator.start(ClassPool)public void onLoad(ClassPool pool, java.lang.String classname)
onLoad in interface Translatorpool - the ClassPool that this translator
should use.classname - the name of the class being loaded.Translator.onLoad(ClassPool,String)public boolean isProxyClass(java.lang.String name)
true if the specified class is a proxy class
recorded by makeProxyClass().name - a fully-qualified class namepublic boolean makeProxyClass(java.lang.Class clazz)
throws CannotCompileException,
NotFoundException
clazz - the class referenced
through the proxy class.false if the proxy class
has been already produced.CannotCompileExceptionNotFoundExceptionprivate CtClass produceProxyClass(CtClass orgclass, java.lang.Class orgRtClass) throws CannotCompileException, NotFoundException
private CtClass toCtClass(java.lang.Class rtclass) throws NotFoundException
NotFoundExceptionprivate CtClass[] toCtClass(java.lang.Class[] rtclasses) throws NotFoundException
NotFoundExceptionprivate void addMethods(CtClass proxy, java.lang.reflect.Method[] ms) throws CannotCompileException, NotFoundException
private void modifySuperclass(CtClass orgclass) throws CannotCompileException, NotFoundException