public class EnhancementOperationImpl extends java.lang.Object implements EnhancementOperation
EnhancementOperationthat knows how to
collect class changes from enhancements. The method getConstructor() finalizes the
enhancement into a ComponentConstructor.| Constructor and Description |
|---|
EnhancementOperationImpl(org.apache.hivemind.ClassResolver classResolver,
IComponentSpecification specification,
java.lang.Class baseClass,
org.apache.hivemind.service.ClassFactory classFactory,
org.apache.commons.logging.Log log) |
| Modifier and Type | Method and Description |
|---|---|
void |
addField(java.lang.String name,
java.lang.Class type)
Adds a field to the enhanced class; the field will be private and use the provided name and
type.
|
java.lang.String |
addInjectedField(java.lang.String fieldName,
java.lang.Class fieldType,
java.lang.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,
java.lang.String methodBody,
org.apache.hivemind.Location location)
Adds a method to the enhanced class.
|
void |
claimProperty(java.lang.String propertyName)
Claims a property.
|
void |
claimReadonlyProperty(java.lang.String propertyName)
Claims a property as read-only.
|
java.lang.Class |
convertTypeName(java.lang.String type)
Converts a type name (an object class name, a primtive name, or an array) into the
corresponding Class object.
|
void |
extendMethodImplementation(java.lang.Class interfaceClass,
org.apache.hivemind.service.MethodSignature methodSignature,
java.lang.String code)
Allows for a kind of distributed construction of a particular method, within a particular
interface.
|
java.util.List |
findUnclaimedAbstractProperties()
Returns a list of the names of existing properties that are not claimed and which have
abstract accessor methods.
|
java.lang.String |
getAccessorMethodName(java.lang.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.
|
java.lang.Class |
getBaseClass()
Returns the base component class, as defined in the specification (or defaulted).
|
java.lang.String |
getClassReference(java.lang.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.
|
java.lang.Class |
getPropertyType(java.lang.String name)
Returns the type of an existing property of the base component class.
|
boolean |
implementsInterface(java.lang.Class interfaceClass)
Returns true if the class implements the specified interface.
|
java.lang.String |
toString() |
void |
validateProperty(java.lang.String name,
java.lang.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.
|
public EnhancementOperationImpl(org.apache.hivemind.ClassResolver classResolver, IComponentSpecification specification, java.lang.Class baseClass, org.apache.hivemind.service.ClassFactory classFactory, org.apache.commons.logging.Log log)
public java.lang.String toString()
toString in class java.lang.Objectpublic void claimProperty(java.lang.String propertyName)
EnhancementOperationclaimProperty in interface EnhancementOperationpublic void claimReadonlyProperty(java.lang.String propertyName)
EnhancementOperationclaimReadonlyProperty in interface EnhancementOperationpublic void addField(java.lang.String name, java.lang.Class type)
EnhancementOperationaddField in interface EnhancementOperationpublic java.lang.String addInjectedField(java.lang.String fieldName, java.lang.Class fieldType, java.lang.Object value)
EnhancementOperationaddInjectedField in interface EnhancementOperationfieldName - 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 nullpublic java.lang.Class convertTypeName(java.lang.String type)
EnhancementOperationconvertTypeName in interface EnhancementOperationpublic java.lang.Class getPropertyType(java.lang.String name)
EnhancementOperationgetPropertyType in interface EnhancementOperationpublic void validateProperty(java.lang.String name, java.lang.Class expectedType)
EnhancementOperationvalidateProperty in interface EnhancementOperationpublic java.lang.String getAccessorMethodName(java.lang.String propertyName)
EnhancementOperationgetAccessorMethodName in interface EnhancementOperationpublic void addMethod(int modifier, org.apache.hivemind.service.MethodSignature sig, java.lang.String methodBody, org.apache.hivemind.Location location)
EnhancementOperationaddMethod in interface EnhancementOperationmodifier - as defined by Modifier, typically
Modifier.PUBLICsig - 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 java.lang.Class getBaseClass()
EnhancementOperationgetBaseClass in interface EnhancementOperationpublic java.lang.String getClassReference(java.lang.Class clazz)
EnhancementOperationgetClassReference in interface EnhancementOperationpublic ComponentConstructor getConstructor()
public void extendMethodImplementation(java.lang.Class interfaceClass, org.apache.hivemind.service.MethodSignature methodSignature, java.lang.String code)
EnhancementOperationAt 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 EnhancementOperationinterfaceClass - 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(java.lang.Class interfaceClass)
EnhancementOperationEnhancementOperation.extendMethodImplementation(Class, MethodSignature, String).implementsInterface in interface EnhancementOperationpublic java.util.List findUnclaimedAbstractProperties()
EnhancementOperationfindUnclaimedAbstractProperties in interface EnhancementOperation