|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.javassist.reflect.Reflection
public class Reflection
The class implementing the reflection mechanism.
This class is used with ClassPool
.
Note that it implements an interface javassist.Translator
.
If a class is reflective, then all the method invocations on every instance of that class are intercepted by the runtime metaobject controlling that instance. To do this, the original class file representing a reflective class:
class Person { public int f(int i) { return i + 1; } public int value; }
is modified so that it represents a class:
class Person implements Metalevel { public int _original_f(int i) { return i + 1; } public int f(int i) { delegate to the metaobject } public int value; public int _r_value() { read "value" } public void _w_value(int v) { write "value" } public ClassMetaobject _getClass() { return a class metaobject } public Metaobject _getMetaobject() { return a metaobject } public void _setMetaobject(Metaobject m) { change a metaobject } }
ClassMetaobject
,
Metaobject
,
Loader
,
Compiler
,
ClassPool
,
Translator
Constructor Summary | |
---|---|
Reflection()
Constructs a new Reflection object. |
Method Summary | |
---|---|
boolean |
makeReflective(java.lang.Class clazz,
java.lang.Class metaobject,
java.lang.Class metaclass)
Produces a reflective class. |
boolean |
makeReflective(CompileTimeClass clazz,
CompileTimeClass metaobject,
CompileTimeClass metaclass)
Produces a reflective class. |
boolean |
makeReflective(java.lang.String classname,
java.lang.String metaobject,
java.lang.String metaclass)
Produces a reflective class. |
void |
onWrite(ClassPool pool,
java.lang.String classname)
Inserts hooks for intercepting accesses to the fields declared in reflective classes. |
void |
start(ClassPool pool)
Initializes. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Reflection()
Reflection
object.
Method Detail |
---|
public void start(ClassPool pool) throws NotFoundException
start
in interface Translator
pool
- the ClassPool
that this translator
is attached to.
NotFoundException
ClassPool.ClassPool(ClassPool,Translator)
,
ClassPool.getDefault(Translator)
public void onWrite(ClassPool pool, java.lang.String classname) throws CannotCompileException, NotFoundException
onWrite
in interface Translator
pool
- the ClassPool
that this translator
is attached to.classname
- a fully-qualified class name
CannotCompileException
NotFoundException
ClassPool.writeFile(String)
,
ClassPool.writeFile(String, String)
,
ClassPool.write(String)
,
ClassPool.write(String,DataOutputStream)
public boolean makeReflective(java.lang.String classname, java.lang.String metaobject, java.lang.String metaclass) throws CannotCompileException, NotFoundException
classname
- the name of the reflective classmetaobject
- the class name of metaobjects.metaclass
- the class name of the class metaobject.
false
if the class is already reflective.
CannotCompileException
NotFoundException
Metaobject
,
ClassMetaobject
public boolean makeReflective(java.lang.Class clazz, java.lang.Class metaobject, java.lang.Class metaclass) throws CannotCompileException, NotFoundException
clazz
- the reflective class.metaobject
- the class of metaobjects.
It must be a subclass of
Metaobject
.metaclass
- the class of the class metaobject.
It must be a subclass of
ClassMetaobject
.
false
if the class is already reflective.
CannotCompileException
NotFoundException
Metaobject
,
ClassMetaobject
public boolean makeReflective(CompileTimeClass clazz, CompileTimeClass metaobject, CompileTimeClass metaclass) throws CannotCompileException, NotFoundException
CtClass
object and makes it reflective.
If the super class is also made reflective, it must be done
before the sub class.
clazz
- the reflective class.metaobject
- the class of metaobjects.
It must be a subclass of
Metaobject
.metaclass
- the class of the class metaobject.
It must be a subclass of
ClassMetaobject
.
false
if the class is already reflective.
CannotCompileException
NotFoundException
Metaobject
,
ClassMetaobject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |