org.apache.tapestry.enhance
Class DefaultComponentClassEnhancer

java.lang.Object
  extended by org.apache.tapestry.enhance.DefaultComponentClassEnhancer
All Implemented Interfaces:
IComponentClassEnhancer

public class DefaultComponentClassEnhancer
extends Object
implements IComponentClassEnhancer

Default implementation of IComponentClassEnhancer.

Since:
3.0
Version:
$Id: DefaultComponentClassEnhancer.java 385802 2006-03-14 13:47:10Z jkuhnert $
Author:
Howard Lewis Ship

Constructor Summary
DefaultComponentClassEnhancer(IResourceResolver resolver, boolean disableValidation)
           
 
Method Summary
protected  Class constructComponentClass(IComponentSpecification specification, String className)
          Returns the class to be used for the component, which is either the class with the given name, or an enhanced subclass.
protected  ComponentClassFactory createComponentClassFactory(IComponentSpecification specification, Class componentClass)
          Constructs a new factory for enhancing the specified class.
protected  IEnhancedClassFactory createEnhancedClassFactory()
           
protected  Class getCachedClass(IComponentSpecification specification)
           
 Class getEnhancedClass(IComponentSpecification specification, String className)
          Used to access the class for a given component (or page).
 IResourceResolver getResourceResolver()
           
 void reset()
          Clears all cached data for the enhancer; this includes references to enhanced classes.
protected  void storeCachedClass(IComponentSpecification specification, Class cachedClass)
           
protected  void validateEnhancedClass(Class subject, String className, IComponentSpecification specification)
          Invoked to validate that an enhanced class is acceptible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultComponentClassEnhancer

public DefaultComponentClassEnhancer(IResourceResolver resolver,
                                     boolean disableValidation)
Parameters:
resolver - resource resolver used to locate classes
disableValidation - if true, then validation (of unimplemented abstract methods) is skipped
Method Detail

createEnhancedClassFactory

protected IEnhancedClassFactory createEnhancedClassFactory()

reset

public void reset()
Description copied from interface: IComponentClassEnhancer
Clears all cached data for the enhancer; this includes references to enhanced classes.

Specified by:
reset in interface IComponentClassEnhancer

getResourceResolver

public IResourceResolver getResourceResolver()

getEnhancedClass

public Class getEnhancedClass(IComponentSpecification specification,
                              String className)
Description copied from interface: IComponentClassEnhancer
Used to access the class for a given component (or page). Returns the specified class, or an enhanced version of the class if the component requires enhancement.

Specified by:
getEnhancedClass in interface IComponentClassEnhancer
Parameters:
specification - the specification for the component
className - the name of base class to enhance, as extracted from the specification (or possibly, from a default).

storeCachedClass

protected void storeCachedClass(IComponentSpecification specification,
                                Class cachedClass)

getCachedClass

protected Class getCachedClass(IComponentSpecification specification)

constructComponentClass

protected Class constructComponentClass(IComponentSpecification specification,
                                        String className)
Returns the class to be used for the component, which is either the class with the given name, or an enhanced subclass.


createComponentClassFactory

protected ComponentClassFactory createComponentClassFactory(IComponentSpecification specification,
                                                            Class componentClass)
Constructs a new factory for enhancing the specified class. Advanced users may want to provide thier own enhancements to classes and this method is the hook that allows them to provide a subclass of ComponentClassFactory adding those enhancements.


validateEnhancedClass

protected void validateEnhancedClass(Class subject,
                                     String className,
                                     IComponentSpecification specification)
Invoked to validate that an enhanced class is acceptible. Primarily, this is to ensure that the class contains no unimplemented abstract methods or fields. Normally, this kind of checking is done at compile time, but for generated classes, there is no compile time check (!) and you can get runtime errors when accessing unimplemented abstract methods.