|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tapestry.enhance.ComponentClassFactory
Contains the logic for analyzing and enhancing a single component class.
Internally, this class makes use of ClassFabricator
and MethodFabricator
.
Constructor Summary | |
ComponentClassFactory(IResourceResolver resolver,
IComponentSpecification specification,
Class componentClass)
|
Method Summary | |
protected void |
addAutoParameterEnhancer(String parameterName,
IParameterSpecification ps)
|
protected void |
addEnhancer(IEnhancer enhancer)
|
String |
buildMethodName(String prefix,
String propertyName)
Constructs an accessor method name. |
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. |
protected org.apache.bcel.generic.Type |
convertToArgumentType(org.apache.bcel.generic.Type type)
Given an arbitrary type, figures out the correct argument type (for fireObservedChange()) to use. |
void |
createAccessor(org.apache.bcel.generic.Type fieldType,
String fieldName,
String propertyName,
String readMethodName)
Creates an accessor (getter) method for the property. |
org.apache.bcel.classfile.JavaClass |
createEnhancedSubclass()
Invoked by DefaultComponentClassEnhancer to
create, as a JavaClass , an enahanced
subclass of the component class. |
void |
createField(org.apache.bcel.generic.Type fieldType,
String fieldName)
|
void |
createMutator(org.apache.bcel.generic.Type fieldType,
String fieldName,
String propertyName,
boolean isPersistent)
Creates a mutator (aka "setter") method. |
ClassFabricator |
getClassFabricator()
|
org.apache.bcel.generic.Type |
getObjectType(String type)
Given the name of a class, returns the equivalent Type . |
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 |
public ComponentClassFactory(IResourceResolver resolver, IComponentSpecification specification, Class componentClass)
Method Detail |
protected PropertyDescriptor getPropertyDescriptor(String name)
public boolean needsEnhancement()
scanForEnhancements()
to identify any
enhancements needed on the class, returning true
if there are any enhancements to be performed.
public boolean isAbstract(PropertyDescriptor pd)
PropertyDescriptor
is null, or
(if non-null), if either accessor method is abstract (or missing).
public boolean isAbstract(Method m)
public Class convertPropertyType(String type, ILocation location)
type
- to convert to a Classlocation
- of the involved specification element (for exception reporting)public org.apache.bcel.generic.Type getObjectType(String type)
Type
. In addition,
knows about scalar types, arrays of scalar types, java.lang.Object[] and
java.lang.String[].
public String buildMethodName(String prefix, String propertyName)
protected void checkPropertyType(PropertyDescriptor pd, Class propertyType, ILocation location)
protected String checkAccessors(String propertyName, Class propertyType, ILocation location)
protected org.apache.bcel.generic.Type convertToArgumentType(org.apache.bcel.generic.Type type)
public void createMutator(org.apache.bcel.generic.Type fieldType, String fieldName, String propertyName, boolean isPersistent)
fieldType
- type of field value (and type of parameter value)fieldName
- name of field (not property!)propertyName
- name of property (used to construct method name)isPersistent
- if true, adds a call to fireObservedChange()public void createAccessor(org.apache.bcel.generic.Type fieldType, String fieldName, String propertyName, String readMethodName)
fieldType
- the return type for the methodfieldName
- the name of the field (not the name of the property)propertyName
- the name of the property (used to build the name of the method)readMethodName
- if not null, the name of the method to useprotected boolean isMissingProperty(String propertyName)
public org.apache.bcel.classfile.JavaClass createEnhancedSubclass()
DefaultComponentClassEnhancer
to
create, as a 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).
protected void addEnhancer(IEnhancer enhancer)
protected void scanForEnhancements()
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)
.
protected void scanForParameterEnhancements()
scanForEnhancements()
to locate
any enhancements needed for component parameters (this includes
binding properties and connected parameter property).
protected void scanForSpecifiedPropertyEnhancements()
protected void scanForBindingProperty(String parameterName, IParameterSpecification ps)
protected void scanForParameterProperty(String parameterName, IParameterSpecification ps)
protected void addAutoParameterEnhancer(String parameterName, IParameterSpecification ps)
protected void scanForSpecifiedProperty(IPropertySpecification ps)
public void createField(org.apache.bcel.generic.Type fieldType, String fieldName)
public ClassFabricator getClassFabricator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |