|
JAC project AOPSYS CEDRIC & LIP6 labs |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.jac.core.rtti.ClassRepository
This class defines the class repository of the rtti aspect.
It contains class items that are field and method items agregates.
ClassItem
,
MethodItem
,
FieldItem
,
CollectionItem
Field Summary | |
protected static ClassRepository |
classRepository
Store the sole instance of class repository. |
Hashtable |
names
Reverse hashtable to find an class item from its name |
Hashtable |
objects
Link class items to their names |
static Class |
wrappeeClass
Stores the Wrappee class. |
Constructor Summary | |
ClassRepository()
The default constructor will set the classRepository field to the right value (singleton pattern). |
Method Summary | |
static void |
addAccessedFields(Class cl,
String methodName,
String[] fieldNames)
Adds a set of accessed fields to a method. |
static void |
addAddedCollections(Class cl,
String methodName,
String[] collectionNames)
Adds a set of added collections to a method. |
void |
addInvokedMethod(String className,
String methodSign,
InvokeInfo invokeInfo)
Tells that a method invokes another method |
void |
addltAccessedField(String className,
String methodSign,
String fieldName)
Adds an accessed field for a given method. |
void |
addltAddedCollection(String className,
String methodSign,
String fieldName)
Tells that a method calls add on a collection field |
void |
addltModifiedCollection(String className,
String methodSign,
String fieldName)
Tells that a method calls modifies the content of a collection field |
void |
addltModifiedField(String className,
String methodSign,
String fieldName)
Adds a modified field for a given method. |
void |
addltRemovedCollection(String className,
String methodSign,
String fieldName)
Tells that a method calls remove on a collection field |
void |
addltReturnedField(String className,
String methodSign,
String fieldName)
Tells that a method returns the value of field |
void |
addltSetField(String className,
String methodSign,
String fieldName)
Tells that a method is the setter of a field (sets the field with the value of a parameter) |
static void |
addRemovedCollections(Class cl,
String methodName,
String[] collectionNames)
Adds a set of removed collections to a method. |
static void |
addWrittenFields(Class cl,
String methodName,
String[] fieldNames)
Adds a set of written fields to a method. |
void |
buildDefaultFieldRTTI(ClassItem cli)
|
ClassItem |
buildDefaultRTTI(Class cl)
This method builds the default RTTI for a given class name and returns a corresponding class item. |
void |
dump()
Dump all the registered classes in this class repository. |
static void |
fillDirectFieldAccess(Class cl)
Fill the direct access to fields hashtable for a given class. |
static Hashtable |
fillDirectMethodAccess(Class cl)
Fill the direct access to methods hashtable for a given class. |
static ClassRepository |
get()
Get the sole instance of class repository. |
ClassItem |
getClass(Class cl)
This method returns the class item that corresponds to the given class. |
ClassItem |
getClass(Object object)
This method returns the class item that corresponds to the given object class. |
ClassItem |
getClass(String name)
This method returns an existing class from its name. |
Object[] |
getClasses()
Return all the registered classes as an array. |
ClassInfo |
getClassInfo(String className)
Returns the class info of a class |
static Hashtable |
getDirectFieldAccess(Class cl)
Returns a Hashtable that maps fields with their names. |
static Method[] |
getDirectMethodAccess(Class cl,
String name)
Return an array of methods that correspond to the given class and given method name. |
static String[] |
getGettersNames(Class cl)
Get getter names. |
MethodInfo |
getMethodInfo(String className,
String method)
|
static String[] |
getMethodsName(Class cl)
Get method names. |
static String[] |
getModifiersNames(Class cl)
Get modifiers names. |
String |
getName(Object object)
Returns the name of a registered class. |
Object[] |
getNames()
Return the names of the registered classes as an array. |
ClassItem |
getNonPrimitiveClass(String className)
|
Object |
getObject(String logicalName)
Return a registered classes for a given logical name. |
MetaItem |
getVirtualClass(String name)
Returns a ClassItem or a VirtualClassItem from its name. |
VirtualClassItem |
getVirtualClassStrict(String name)
Returns a VirtualClassItem from its name. |
void |
ignoreFields(String packageExpr)
|
static Object |
instantiate(Class type,
String value)
|
static Object |
invokeDirect(Class cl,
String methodName,
Object o,
Object[] params)
Call a directly acceded method. |
static boolean |
isDefaultConstructorAdded(Class cl)
Returns true is this class defautlt constructor (the one with no parameter) has been added by JAC at class load-time. |
static boolean |
isJacField(String fieldName)
Return true if the field is added by JAC at class load-time. |
static boolean |
isJacMethod(String methodName)
Return true if the method is added by JAC at class load-time. |
boolean |
isRegistered(String logicalName)
Returns true if a class is registered with this name. |
static boolean |
isSystemField(String fieldName)
Tells if the field is a "system" field, such as a field added by the compiler for class objects. |
boolean |
register(String logicalName,
Object object)
Register a new class into the class repository. |
void |
setCallSuper(String className,
String method)
Tells that a method calls the super method |
void |
setClassInfo(String className,
ClassInfo classInfo)
|
void |
setCollectionIndexArgument(String className,
String methodSign,
int argument)
Tells that a method's parameter is used as an index of a collection field |
void |
setltIsGetter(String className,
String methodSign,
boolean isGetter)
Tells wether a method is a getter of a field or not |
void |
unregister(String logicalName)
Unregister a class from the repository. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static transient ClassRepository classRepository
public static Class wrappeeClass
public Hashtable objects
public Hashtable names
Constructor Detail |
public ClassRepository()
Method Detail |
public ClassInfo getClassInfo(String className)
LoadtimeRTTI
getClassInfo
in interface LoadtimeRTTI
public void setClassInfo(String className, ClassInfo classInfo)
setClassInfo
in interface LoadtimeRTTI
public MethodInfo getMethodInfo(String className, String method)
public void addltModifiedField(String className, String methodSign, String fieldName)
This method is automatically called at load-time by the JAC classloader through bytecode analysis.
addltModifiedField
in interface LoadtimeRTTI
methodSign
- the method signature of the form
packagepath.classname.methodname
fieldName
- the name of the field that is modified by the
methodpublic void addltSetField(String className, String methodSign, String fieldName)
LoadtimeRTTI
addltSetField
in interface LoadtimeRTTI
public void addltAccessedField(String className, String methodSign, String fieldName)
This method is automatically called at load-time by the JAC classloader through bytecode analysis.
addltAccessedField
in interface LoadtimeRTTI
methodSign
- the method signature of the form
packagepath.classname.methodname
fieldName
- the name of the field that is accessed by the
methodpublic void addltReturnedField(String className, String methodSign, String fieldName)
LoadtimeRTTI
addltReturnedField
in interface LoadtimeRTTI
public void setltIsGetter(String className, String methodSign, boolean isGetter)
LoadtimeRTTI
setltIsGetter
in interface LoadtimeRTTI
public void addltAddedCollection(String className, String methodSign, String fieldName)
LoadtimeRTTI
addltAddedCollection
in interface LoadtimeRTTI
public void addltRemovedCollection(String className, String methodSign, String fieldName)
LoadtimeRTTI
addltRemovedCollection
in interface LoadtimeRTTI
public void addltModifiedCollection(String className, String methodSign, String fieldName)
LoadtimeRTTI
addltModifiedCollection
in interface LoadtimeRTTI
public void setCollectionIndexArgument(String className, String methodSign, int argument)
LoadtimeRTTI
setCollectionIndexArgument
in interface LoadtimeRTTI
public void addInvokedMethod(String className, String methodSign, InvokeInfo invokeInfo)
LoadtimeRTTI
addInvokedMethod
in interface LoadtimeRTTI
public void setCallSuper(String className, String method)
LoadtimeRTTI
setCallSuper
in interface LoadtimeRTTI
public static ClassRepository get()
public static Hashtable fillDirectMethodAccess(Class cl)
This is used to optimize the method calls when you only have the method name.
cl
- the class to treat.getDirectMethodAccess(Class,String)
public static void fillDirectFieldAccess(Class cl)
This is used to optimize the access of protected and private fields.
cl
- the class to treat.public static Hashtable getDirectFieldAccess(Class cl)
For efficiency, the programmer should use this method instead of using the Java refection API to retrives values of protected or private fields within a class and all its superclasses.
cl
- the class where the field is supposed to be
fillDirectFieldAccess(Class)
public static Object invokeDirect(Class cl, String methodName, Object o, Object[] params) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
cl
- the class that supports the methodmethodName
- the method to callo
- the object to call the method onparams
- the arguments
NoSuchMethodException
InvocationTargetException
IllegalAccessException
getDirectMethodAccess(Class,String)
public static Method[] getDirectMethodAccess(Class cl, String name)
For efficiency, the programmer should use this method instead of using the Java refection API.
cl
- the class where the method is supposed to bename
- the method name
null
inside if none method
matched (this ugly result was introduced for backward
compatibility)fillDirectMethodAccess(Class)
public static boolean isDefaultConstructorAdded(Class cl)
cl
- the class to test
public static boolean isJacMethod(String methodName)
methodName
- the method to check
public static boolean isJacField(String fieldName)
fieldName
- name of the fieldpublic static boolean isSystemField(String fieldName)
fieldName
- name of the fieldpublic static String[] getMethodsName(Class cl)
public static String[] getModifiersNames(Class cl)
cl
- the class
public static String[] getGettersNames(Class cl)
cl
- the class
public static void addWrittenFields(Class cl, String methodName, String[] fieldNames)
This method shortcuts the writting of RTTI aspects for programs. Equivalent effects can be achieved by using the RTTI aspect API.
cl
- the involved classmethodName
- the method namefieldNames
- the set of fields that are written by this
methodAbstractMethodItem.addWrittenField(FieldItem)
public static void addAccessedFields(Class cl, String methodName, String[] fieldNames)
This method shortcuts the writting of RTTI aspects for programs. Equivalent effects can be achieved by using the RTTI aspect API.
cl
- the involved classmethodName
- the method namefieldNames
- the set of fields that are accessed by this
methodMethodItem.addAccessedField(FieldItem)
public static void addAddedCollections(Class cl, String methodName, String[] collectionNames)
This method shortcuts the writting of RTTI aspects for programs. Equivalent effects can be achieved by using the RTTI aspect API.
cl
- the involved classmethodName
- the method nameMethodItem.addAddedCollection(CollectionItem)
public static void addRemovedCollections(Class cl, String methodName, String[] collectionNames)
This method shortcuts the writting of RTTI aspects for programs. Equivalent effects can be achieved by using the RTTI aspect API.
cl
- the involved classmethodName
- the method nameMethodItem.addRemovedCollection(CollectionItem)
public ClassItem getClass(String name)
If the class is not registered yet, the class repository
automatically builds default runtime informations (using naming
conventions), and seamlessly registers the new
ClassItem
instance into the class repository.
Note: in case of manual class registrations, a class must be registered with its full name to avoid name conflicts.
name
- the name of the class to get
public MetaItem getVirtualClass(String name)
name
- the name of the class to find
public VirtualClassItem getVirtualClassStrict(String name)
name
- the name of the class to find
public ClassItem getClass(Object object)
object
- the object to get the class item
getClass(String)
public ClassItem getClass(Class cl)
getClass(String)
public ClassItem getNonPrimitiveClass(String className)
public void ignoreFields(String packageExpr)
public ClassItem buildDefaultRTTI(Class cl)
public void buildDefaultFieldRTTI(ClassItem cli)
public boolean register(String logicalName, Object object)
logicalName
- the key that allows to find the classobject
- the class to register
unregister(String)
public void unregister(String logicalName)
logicalName
- the class nameregister(String,Object)
public boolean isRegistered(String logicalName)
logicalName
- the key that allows to find the classregister(String,Object)
public Object[] getClasses()
Reverse operation is getNames()
.
register(String,Object)
,
getNames()
public Object[] getNames()
register(String,Object)
public Object getObject(String logicalName)
Return null
if the name does not correspond to
any registered class or if logicalName
is null.
Reverse operation is getName(Object)
.
logicalName
- the key that allows to find the class
register(String,Object)
,
getName(Object)
public String getName(Object object)
Reverse operation is getObject(String)
.
object
- the class to get the name of
register(String,Object)
,
getObject(String)
public void dump()
public static Object instantiate(Class type, String value)
|
Contact JAC development team: Renaud Pawlak Lionel Seinturier Laurent Martelli |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |