|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry.enhance.EnhancementOperationImpl
public class EnhancementOperationImpl
Implementation of EnhancementOperation
that
knows how to collect class changes from enhancements. The method
getConstructor()
finalizes the enhancement into a
ComponentConstructor
.
Constructor Summary | |
---|---|
EnhancementOperationImpl(org.apache.hivemind.ClassResolver classResolver,
IComponentSpecification specification,
Class baseClass,
org.apache.hivemind.service.ClassFactory classFactory,
Log log)
|
Method Summary | |
---|---|
void |
addField(String name,
Class type)
Adds a field to the enhanced class; the field will be private and use the provided name and type. |
String |
addInjectedField(String fieldName,
Class fieldType,
Object value)
Adds a field containing an initial value, which is injected into the class via its fabricated constructor. |
void |
addMethod(int modifier,
org.apache.hivemind.service.MethodSignature sig,
String methodBody,
org.apache.hivemind.Location location)
Adds a method to the enhanced class. |
boolean |
canClaimAsReadOnlyProperty(String propertyName)
Checks to see if the specified property can be claimed as read only. |
void |
claimProperty(String propertyName)
Claims a property. |
void |
claimReadonlyProperty(String propertyName)
Claims a property as read-only. |
Class |
convertTypeName(String type)
Converts a type name (an object class name, a primtive name, or an array) into the corresponding Class object. |
void |
extendMethodImplementation(Class interfaceClass,
org.apache.hivemind.service.MethodSignature methodSignature,
String code)
Allows for a kind of distributed construction of a particular method, within a particular interface. |
List |
findUnclaimedAbstractProperties()
Returns a list of the names of existing properties that are not claimed and which have abstract accessor methods. |
String |
getAccessorMethodName(String propertyName)
Returns the name of the accessor method for the given property (if it exists in the component base class), or fabricates a new name if it does not. |
Class |
getBaseClass()
Returns the base component class, as defined in the specification (or defaulted). |
String |
getClassReference(Class clazz)
Returns a reference to a particular class. |
ComponentConstructor |
getConstructor()
Returns an object that can be used to construct instances of the enhanced component subclass. |
Class |
getPropertyType(String name)
Returns the type of an existing property of the base component class. |
IComponentSpecification |
getSpecification()
The specification defined for the component class being enhanced. |
boolean |
implementsInterface(Class interfaceClass)
Returns true if the class implements the specified interface. |
String |
toString()
|
void |
validateProperty(String name,
Class expectedType)
Confirms that the named property either doesn't exist (in the component base class), or that the type of the property exactly matches the indicated type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EnhancementOperationImpl(org.apache.hivemind.ClassResolver classResolver, IComponentSpecification specification, Class baseClass, org.apache.hivemind.service.ClassFactory classFactory, Log log)
Method Detail |
---|
public String toString()
toString
in class Object
public void claimProperty(String propertyName)
EnhancementOperation
claimProperty
in interface EnhancementOperation
public boolean canClaimAsReadOnlyProperty(String propertyName)
canClaimAsReadOnlyProperty
in interface EnhancementOperation
propertyName
- The property to check.
public void claimReadonlyProperty(String propertyName)
EnhancementOperation
claimReadonlyProperty
in interface EnhancementOperation
public void addField(String name, Class type)
EnhancementOperation
addField
in interface EnhancementOperation
public String addInjectedField(String fieldName, Class fieldType, Object value)
EnhancementOperation
addInjectedField
in interface EnhancementOperation
fieldName
- The default name for the field, used if a new field (and
contructor argument) is being created. Only used if a field
for the value doesn't exist.fieldType
- The type of the field to be created.value
- the value to be referenced, which may not be null
public Class convertTypeName(String type)
EnhancementOperation
convertTypeName
in interface EnhancementOperation
public Class getPropertyType(String name)
EnhancementOperation
getPropertyType
in interface EnhancementOperation
name
- The property name.
public void validateProperty(String name, Class expectedType)
EnhancementOperation
validateProperty
in interface EnhancementOperation
public String getAccessorMethodName(String propertyName)
EnhancementOperation
getAccessorMethodName
in interface EnhancementOperation
propertyName
- The property to get an accessor method name of.
public void addMethod(int modifier, org.apache.hivemind.service.MethodSignature sig, String methodBody, org.apache.hivemind.Location location)
EnhancementOperation
addMethod
in interface EnhancementOperation
modifier
- as defined by Modifier
, typically
Modifier.PUBLIC
sig
- the method signature (defining name, return type, etc.)methodBody
- a Javassist code snippet for the method bodylocation
- a location used to identify "why" the method was added; the
location may later be used to describe conflicts. May not be
null.public Class getBaseClass()
EnhancementOperation
getBaseClass
in interface EnhancementOperation
public String getClassReference(Class clazz)
EnhancementOperation
getClassReference
in interface EnhancementOperation
clazz
- The class to get a string equivalent reference of.
public ComponentConstructor getConstructor()
public void extendMethodImplementation(Class interfaceClass, org.apache.hivemind.service.MethodSignature methodSignature, String code)
EnhancementOperation
At this time, this works best for void methods (since there isn't an easy way to ensure code would be inserted before a final return statement).
extendMethodImplementation
in interface EnhancementOperation
interfaceClass
- the interface containing the method. If the base class does
not implement the interface, then the enhanced class will have
the interface added.methodSignature
- the signature of the method to be added.code
- the Javassist markup to be added to the body of the method.public boolean implementsInterface(Class interfaceClass)
EnhancementOperation
EnhancementOperation.extendMethodImplementation(Class, MethodSignature, String)
.
implementsInterface
in interface EnhancementOperation
interfaceClass
- The class to check if the base class implements.
public List findUnclaimedAbstractProperties()
EnhancementOperation
findUnclaimedAbstractProperties
in interface EnhancementOperation
public IComponentSpecification getSpecification()
EnhancementOperation
getSpecification
in interface EnhancementOperation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |