|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectraccoon.core.bean.descriptor.BeanAnalyzer
public class BeanAnalyzer
The default bean analyzer offered by the Raccoon Framework.
This Bean Analyzer component uses the reflexion service of the JDK to extract from any given Class the valid Castor bean properties (get<Property>/set<Property>) and the valid Raccoon bean properties (get<Property>/set<Property>/add<Property>). Furthermore the result of the introspection is cached for improoved acces time and if necessary lazy introspection can be applied.
Field Summary | |
---|---|
static java.lang.Class[] |
ATOMIC_CLASSES
The official class types that are considered atomic by the Raccoon Framework. |
Constructor Summary | |
---|---|
BeanAnalyzer()
|
Method Summary | |
---|---|
IBeanDescriptor |
introspect(java.lang.Class pJavaBean)
Introspects the class and returns the description of the class. |
boolean |
isArray(java.lang.Class pClass)
Checks if this provided class is an array element. |
boolean |
isAtomic(java.lang.Class pClass)
Checks if this provided class is an atomic element. |
boolean |
isCollection(java.lang.Class pClass)
Checks if this provided class is a collection element. |
boolean |
isLazyIntrospect()
Is lazy introspection activated, default is true . |
protected void |
logDroppedMethod(java.lang.String pReason,
java.lang.reflect.Method pMethod)
Sends to the log file of this instance information regarding a bean method that is unused. |
protected IBeanDescriptor |
parseBean(java.lang.Class pClassToIntrospect)
Introspects the bean in order to determine all bean methods that are available. |
protected java.util.ArrayList |
retainAssociatedAccessors(java.util.ArrayList pSetters,
java.util.ArrayList pGetters)
For each getter method, searches for a corresponding setter with the same type. |
protected java.util.ArrayList |
searchForAdders(java.util.ArrayList pPropertyDesc,
java.util.ArrayList pAdders)
For each get/set property see if we can locate an associated adder. |
void |
setLazyIntrospect(boolean pLazyIntrospect)
Define the introspection mode. |
void |
setLogger(ILogger pLogger)
Assigns the logger to the component. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Class[] ATOMIC_CLASSES
Constructor Detail |
---|
public BeanAnalyzer()
Method Detail |
---|
public void setLogger(ILogger pLogger) throws java.lang.IllegalStateException
setLogger
in interface ILogable
pLogger
- the logging instance to use.
java.lang.IllegalStateException
- if the component is already loaded, valid only if the component implements the ILoadable
interface.public boolean isLazyIntrospect()
true
.
public void setLazyIntrospect(boolean pLazyIntrospect)
pLazyIntrospect
- the mode of introspectionpublic boolean isAtomic(java.lang.Class pClass)
isAtomic
in interface IBeanAnalyzer
pClass
- the class to analyse.
true
if this class is atomicpublic boolean isArray(java.lang.Class pClass)
isArray
in interface IBeanAnalyzer
pClass
- the class to analyse.
true
if this class is an arraypublic boolean isCollection(java.lang.Class pClass)
isCollection
in interface IBeanAnalyzer
pClass
- the class to analyse.
true
if this class is a collectionCollection
public IBeanDescriptor introspect(java.lang.Class pJavaBean) throws RaccoonException
introspect
in interface IBeanAnalyzer
pJavaBean
- the class that is to be introspected, should be a Java Bean.
RaccoonException
- if the service isn't running.
RaccoonException
- if the class can't be analyzedprotected IBeanDescriptor parseBean(java.lang.Class pClassToIntrospect) throws IntrospectionException
setGirlFriends
thinggetGirlFriends
thing, if the thing doesn't
throw a null pointer exceptionaddGirlFriend
, my favoriteisGirlFriend
hasBoyFriend
...
ugghh
pClassToIntrospect
- the java bean that is to be introspected.
IntrospectionException
- if the introspection fails for some reason (java security exception for example).protected java.util.ArrayList searchForAdders(java.util.ArrayList pPropertyDesc, java.util.ArrayList pAdders) throws IntrospectionException
pPropertyDesc
- the list of current BeanProperty
instances that only have the defined setters and
getters.pAdders
- the list of methods whose name starts with add
BeanProperty
where the understandable adders have been appended.
IntrospectionException
- if the associated getter/setter and adder of a given set are invalid (should be
considered as a bug)protected java.util.ArrayList retainAssociatedAccessors(java.util.ArrayList pSetters, java.util.ArrayList pGetters) throws IntrospectionException
pSetters
and pGetters
are those that
are unmatched.
pSetters
- the array of methods that are possible setter methods.pGetters
- the array of methods that are possible getter methods.
BeanProperty
elements containing the get/set pair only.
IntrospectionException
- if the PropertyDescriptor refuses and instanciation (should be a bug though)protected final void logDroppedMethod(java.lang.String pReason, java.lang.reflect.Method pMethod)
pReason
- the reason for which the method is being ignoredpMethod
- the method that is ignored.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |