org.apache.commons.clazz.reflect
Class ReflectedClazz

java.lang.Object
  extended by org.apache.commons.clazz.common.ClazzElementSupport
      extended by org.apache.commons.clazz.Clazz
          extended by org.apache.commons.clazz.reflect.ReflectedClazz
All Implemented Interfaces:
ClazzElement
Direct Known Subclasses:
ExtendedReflectedClazz, StandardReflectedClazz

public abstract class ReflectedClazz
extends Clazz

This implementation of Clazz is based on Java reflection.

Version:
$Id: ReflectedClazz.java 155436 2005-02-26 13:17:48Z dirkv $
Author:
Dmitri Plotnikov

Field Summary
 
Fields inherited from class org.apache.commons.clazz.Clazz
EXTENDED_CLAZZ_MODEL, STANDARD_CLAZZ_MODEL
 
Constructor Summary
ReflectedClazz(ClazzLoader loader, Class instanceClass)
           
 
Method Summary
protected  void addInstanceFactory(ClazzInstanceFactory factory)
           
protected  void addOperation(ClazzOperation operation)
           
protected  void addProperty(ClazzProperty property)
           
protected  BeanInfo getBeanInfo()
          Performs BeanInfo lookup in the same manner as the standard java.beans.Introspector.
 List getDeclaredOperations()
          Returns all Operations declared by this clazz, not its superclazzes.
 List getDeclaredProperties()
          Returns properties introduced by this clazz as compared to the superclazz.
 Class getInstanceClass()
          Returns the class of instances created by the newInstance() method.
 List getInstanceFactories()
          Returns all InstanceFactories for this clazz.
 ClazzInstanceFactory getInstanceFactory(String signature)
          Returns ClazzInstanceFactory for the given signature.
protected abstract  ReflectedInstanceFactoryIntrospector[] getInstanceFactoryIntrospectors()
           
 ClazzOperation getOperation(String signature)
          Returns the Operation for the given signature.
protected abstract  ReflectedOperationIntrospector[] getOperationIntrospectors()
           
 List getOperations()
          Returns all Operations for this clazz.
 List getProperties()
          Returns all properties for this clazz, including those declared by superclazzes.
 ClazzProperty getProperty(String name)
          Returns a ClazzProperty for the given name
protected abstract  ReflectedPropertyIntrospector[] getPropertyIntrospectors()
          The order of introspectors is significant, they are invoked sequencially.
 Class getReflectedClass()
          Returns the class this ReflectedClazz is based upon.
 Clazz getSuperclazz()
          Returns the superclazz for this Clazz, or null if there is none.
protected  void introspectInstanceFactories()
          Override this method to provide an alternate way of mapping constructors, methods (and possibly fields) to InstanceFactories.
protected  void introspectOperations()
          Override this method to provide an alternate way of mapping methods (and possibly fields) to Operations.
protected  void introspectProperties()
          Override this method to provide an alternate way of mapping fields and methods to properties.
 boolean isAssignableFrom(Clazz clazz)
          Overrides the default implementation, checks if the supplied clazz is also a ReflectedClazz and if so invokes isAssignableFrom on the corresponding java classes.
 boolean isLoggingEnabled()
          Returns true if diagnostic is enabled for this clazz
protected  void logPropertyParseResults()
          Prints diagnostics of property introspection.
 void logPropertyParseResults(Object parseResults)
          Called by ReflectedPropertyIntrospector's to log results of introspection, successful or not.
 
Methods inherited from class org.apache.commons.clazz.Clazz
addClazzChangeListener, addClazzLoaderFactory, constructSignature, constructSignature, fireInstanceFactoryAdded, fireInstanceFactoryRemoved, fireOperationAdded, fireOperationRemoved, firePropertyAdded, firePropertyRemoved, getCanonicalClassName, getClazz, getClazz, getClazzLoader, getClazzLoader, getClazzLoaderFactory, getDefaultClazzLoader, getDefaultClazzModel, getName, getPackageName, getShortClassName, newInstance, newInstance, removeClazzChangeListener, setDefaultClazzModel
 
Methods inherited from class org.apache.commons.clazz.common.ClazzElementSupport
getAttribute, getAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.clazz.ClazzElement
getAttribute, getAttributes
 

Constructor Detail

ReflectedClazz

public ReflectedClazz(ClazzLoader loader,
                      Class instanceClass)
Parameters:
loader -
instanceClass -
Method Detail

getInstanceClass

public Class getInstanceClass()
Description copied from class: Clazz
Returns the class of instances created by the newInstance() method.

Specified by:
getInstanceClass in class Clazz

getPropertyIntrospectors

protected abstract ReflectedPropertyIntrospector[] getPropertyIntrospectors()
The order of introspectors is significant, they are invoked sequencially. Once a property has been recoginzed by an introspector, it will not be overridden by subsequently invoked ones.


getOperationIntrospectors

protected abstract ReflectedOperationIntrospector[] getOperationIntrospectors()
See Also:
getPropertyIntrospectors()

getInstanceFactoryIntrospectors

protected abstract ReflectedInstanceFactoryIntrospector[] getInstanceFactoryIntrospectors()
See Also:
getPropertyIntrospectors()

isLoggingEnabled

public boolean isLoggingEnabled()
Returns true if diagnostic is enabled for this clazz


getReflectedClass

public Class getReflectedClass()
Returns the class this ReflectedClazz is based upon.

Returns:
Class

getSuperclazz

public Clazz getSuperclazz()
Description copied from class: Clazz
Returns the superclazz for this Clazz, or null if there is none.

Specified by:
getSuperclazz in class Clazz
See Also:
Clazz.getSuperclazz()

getDeclaredProperties

public List getDeclaredProperties()
Returns properties introduced by this clazz as compared to the superclazz. Note, that some of the methods comprizing a property may be declared on the superclass. This makes it impossible to build a list of declared properties by looking exclusively at the current class - we have to reflected all properties of this clazz, then all properties of the superclazz and then subtract the latter from the former.

Specified by:
getDeclaredProperties in class Clazz

getProperties

public List getProperties()
Description copied from class: Clazz
Returns all properties for this clazz, including those declared by superclazzes.

Specified by:
getProperties in class Clazz

getProperty

public ClazzProperty getProperty(String name)
Description copied from class: Clazz
Returns a ClazzProperty for the given name

Specified by:
getProperty in class Clazz

addProperty

protected void addProperty(ClazzProperty property)

getOperations

public List getOperations()
Description copied from class: Clazz
Returns all Operations for this clazz.

Specified by:
getOperations in class Clazz

getDeclaredOperations

public List getDeclaredOperations()
Description copied from class: Clazz
Returns all Operations declared by this clazz, not its superclazzes.

Specified by:
getDeclaredOperations in class Clazz
See Also:
Clazz.getDeclaredOperations()

getOperation

public ClazzOperation getOperation(String signature)
Description copied from class: Clazz
Returns the Operation for the given signature. The signature should be formatted as follows: "name(paramClazzName1,...)"

Specified by:
getOperation in class Clazz
See Also:
Clazz.getOperation(java.lang.String)

addOperation

protected void addOperation(ClazzOperation operation)

getInstanceFactories

public List getInstanceFactories()
Returns all InstanceFactories for this clazz.

Specified by:
getInstanceFactories in class Clazz

getInstanceFactory

public ClazzInstanceFactory getInstanceFactory(String signature)
Description copied from class: Clazz
Returns ClazzInstanceFactory for the given signature. The signature should be formatted as follows: "(paramClazzName1,...)". You can pass null in place of "()".

Specified by:
getInstanceFactory in class Clazz
See Also:
Clazz.getInstanceFactory(java.lang.String)

addInstanceFactory

protected void addInstanceFactory(ClazzInstanceFactory factory)

isAssignableFrom

public boolean isAssignableFrom(Clazz clazz)
Overrides the default implementation, checks if the supplied clazz is also a ReflectedClazz and if so invokes isAssignableFrom on the corresponding java classes.

Overrides:
isAssignableFrom in class Clazz

introspectProperties

protected void introspectProperties()
Override this method to provide an alternate way of mapping fields and methods to properties.


getBeanInfo

protected BeanInfo getBeanInfo()
Performs BeanInfo lookup in the same manner as the standard java.beans.Introspector.


introspectOperations

protected void introspectOperations()
Override this method to provide an alternate way of mapping methods (and possibly fields) to Operations.


introspectInstanceFactories

protected void introspectInstanceFactories()
Override this method to provide an alternate way of mapping constructors, methods (and possibly fields) to InstanceFactories.


logPropertyParseResults

public void logPropertyParseResults(Object parseResults)
Called by ReflectedPropertyIntrospector's to log results of introspection, successful or not.


logPropertyParseResults

protected void logPropertyParseResults()
Prints diagnostics of property introspection.



Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.