org.apache.tapestry.enhance
Class ComponentClassFactory

java.lang.Object
  |
  +--org.apache.tapestry.enhance.ComponentClassFactory

public class ComponentClassFactory
extends Object

Contains the logic for analyzing and enhancing a single component class. Internally, this class makes use of org.apache.tapestry.enhance.ClassFabricator and org.apache.tapestry.enhance.MethodFabricator.

Since:
3.0
Version:
$Id: ComponentClassFactory.java,v 1.16 2003/06/27 03:58:43 mindbridge Exp $
Author:
Howard Lewis Ship

Constructor Summary
ComponentClassFactory(IResourceResolver resolver, IComponentSpecification specification, Class componentClass, IEnhancedClassFactory enhancedClassFactory)
           
 
Method Summary
protected  void addAutoParameterEnhancer(String parameterName, IParameterSpecification ps)
           
protected  String checkAccessors(String propertyName, Class propertyType, ILocation location)
          Checks to see that that class either doesn't provide the property, or does but the accessor(s) are abstract.
protected  void checkPropertyType(PropertyDescriptor pd, Class propertyType, ILocation location)
           
 Class convertPropertyType(String type, ILocation location)
          Given a class name, returns the corresponding class.
 Class createEnhancedSubclass()
          Invoked by DefaultComponentClassEnhancer to create, as a org.apache.bcel.classfile.JavaClass, an enahanced subclass of the component class.
 IEnhancedClass getEnhancedClass()
           
protected  PropertyDescriptor getPropertyDescriptor(String name)
           
 boolean isAbstract(Method m)
          Returns true if the method is null, or is abstract.
 boolean isAbstract(PropertyDescriptor pd)
          Returns true if the PropertyDescriptor is null, or (if non-null), if either accessor method is abstract (or missing).
protected  boolean isMissingProperty(String propertyName)
           
 boolean needsEnhancement()
          Invokes scanForEnhancements() to identify any enhancements needed on the class, returning true if there are any enhancements to be performed.
protected  void scanForBindingProperty(String parameterName, IParameterSpecification ps)
           
protected  void scanForEnhancements()
          Invoked by needsEnhancement() to find any enhancements that may be needed.
protected  void scanForParameterEnhancements()
          Invoked by scanForEnhancements() to locate any enhancements needed for component parameters (this includes binding properties and connected parameter property).
protected  void scanForParameterProperty(String parameterName, IParameterSpecification ps)
           
protected  void scanForSpecifiedProperty(IPropertySpecification ps)
           
protected  void scanForSpecifiedPropertyEnhancements()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentClassFactory

public ComponentClassFactory(IResourceResolver resolver,
                             IComponentSpecification specification,
                             Class componentClass,
                             IEnhancedClassFactory enhancedClassFactory)
Method Detail

getPropertyDescriptor

protected PropertyDescriptor getPropertyDescriptor(String name)

needsEnhancement

public boolean needsEnhancement()
Invokes scanForEnhancements() to identify any enhancements needed on the class, returning true if there are any enhancements to be performed.

isAbstract

public boolean isAbstract(PropertyDescriptor pd)
Returns true if the PropertyDescriptor is null, or (if non-null), if either accessor method is abstract (or missing).

isAbstract

public boolean isAbstract(Method m)
Returns true if the method is null, or is abstract.

convertPropertyType

public Class convertPropertyType(String type,
                                 ILocation location)
Given a class name, returns the corresponding class. In addition, scalar types, arrays of scalar types, java.lang.Object[] and java.lang.String[] are supported.
Parameters:
type - to convert to a Class
location - of the involved specification element (for exception reporting)

checkPropertyType

protected void checkPropertyType(PropertyDescriptor pd,
                                 Class propertyType,
                                 ILocation location)

checkAccessors

protected String checkAccessors(String propertyName,
                                Class propertyType,
                                ILocation location)
Checks to see that that class either doesn't provide the property, or does but the accessor(s) are abstract. Returns the name of the read accessor, or null if there is no such accessor (this is helpful if the beanClass defines a boolean property, where the name of the accessor may be isXXX or getXXX).

isMissingProperty

protected boolean isMissingProperty(String propertyName)

createEnhancedSubclass

public Class createEnhancedSubclass()
Invoked by DefaultComponentClassEnhancer to create, as a org.apache.bcel.classfile.JavaClass, an enahanced subclass of the component class. This means creating a default constructor, new fields, and new accessor and mutator methods. Properties are created for connected parameters, for all formal parameters (the binding property), and for all specified parameters (which may be transient or persistent).

scanForEnhancements

protected void scanForEnhancements()
Invoked by needsEnhancement() to find any enhancements that may be needed. Should create an IEnhancer for each one, and add it to the queue using #addEnhancer(IEnhancer).

scanForParameterEnhancements

protected void scanForParameterEnhancements()
Invoked by scanForEnhancements() to locate any enhancements needed for component parameters (this includes binding properties and connected parameter property).

scanForSpecifiedPropertyEnhancements

protected void scanForSpecifiedPropertyEnhancements()

scanForBindingProperty

protected void scanForBindingProperty(String parameterName,
                                      IParameterSpecification ps)

scanForParameterProperty

protected void scanForParameterProperty(String parameterName,
                                        IParameterSpecification ps)

addAutoParameterEnhancer

protected void addAutoParameterEnhancer(String parameterName,
                                        IParameterSpecification ps)

scanForSpecifiedProperty

protected void scanForSpecifiedProperty(IPropertySpecification ps)

getEnhancedClass

public IEnhancedClass getEnhancedClass()