org.apache.tapestry.enhance
Class ComponentClassFactory

java.lang.Object
  extended by 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 IEnhancedClassFactory.

Since:
3.0
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 an enahanced subclass of the component class.
 IEnhancedClass getEnhancedClass()
           
protected  PropertyDescriptor getPropertyDescriptor(String name)
           
 boolean isAbstract(Method m)
           
 boolean isImplemented(Method m)
           
 boolean isImplemented(PropertyDescriptor pd)
           
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 scanForAbstractClass()
           
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()
           
protected  String translateClassName(String type)
          Translates types from standard Java format to Java VM format.
 
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.


isImplemented

public boolean isImplemented(PropertyDescriptor pd)
Returns:
true if pd is not null and both read/write methods are implemented

isAbstract

public boolean isAbstract(Method m)
Returns:
true if m is not null and is abstract.

isImplemented

public boolean isImplemented(Method m)
Returns:
true if m is not null and not 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)

translateClassName

protected String translateClassName(String type)
Translates types from standard Java format to Java VM format. For example, java.util.Locale remains java.util.Locale, but int[][] is translated to [[I and java.lang.Object[] to [Ljava.lang.Object; This method and its static Map should go into a utility class


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 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.


scanForAbstractClass

protected void scanForAbstractClass()

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()