public interface ClassTransformation extends AnnotationProvider
Component
) but also transforming access to fields, based on
annotations and
naming conventions. Most of the changes are provided by different implementations of
ComponentClassTransformWorker
.
Much of this information is somewhat like ordinary reflection, but applies to a class that has not yet been loaded.
Field types, return types, parameter types and exception types are represented as string names, since any of them may
be a class that has not yet been loaded and transformed as well.
Transformation is primarily about identifying annotations on fields and on methods and changing the class, adding new
interfaces, fields and methods, and deleting some existing fields.
A ClassTransformation contains all the state data specific to a particular class being transformed. A number of
workers will operate upon the ClassTransformation to effect the desired changes before the true class is
loaded into memory.
Instances of this class are not designed to be thread safe, access to an instance should be restricted to a single
thread. In fact, the design of this type is to allow stateless singletons in multiple threads to work on
thread-specific data (within the ClassTransformation).
The majority of methods concern the declared members (field and methods) of a specific class, rather than
any fields or methods inherited from a base class.PlasticClass
Modifier and Type | Method and Description |
---|---|
void |
addComponentEventHandler(String eventType,
int minContextValues,
String methodDescription,
ComponentEventHandler handler)
Deprecated.
Adds advice to the
Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent) method. |
void |
addImplementedInterface(Class interfaceClass)
Deprecated.
Transforms the class to implement the indicated interface.
|
<T> TransformField |
addIndirectInjectedField(Class<T> type,
String suggestedName,
ComponentValueProvider<T> provider)
Deprecated.
Like
addInjectedField(Class, String, Object) , but instead of specifying the value,
a provider for the value is specified. |
String |
addInjectedField(Class type,
String suggestedName,
Object value)
Deprecated.
Defines a new protected instance variable whose initial value is provided
statically, via a
constructor parameter.
|
TransformField |
createField(int modifiers,
String type,
String suggestedName)
Deprecated.
Defines a new declared field for the class.
|
String |
getClassName()
Deprecated.
Returns the fully qualified class name of the class being transformed.
|
TransformField |
getField(String fieldName)
Deprecated.
Locates a declared field by its field name.
|
org.slf4j.Logger |
getLogger()
Deprecated.
Returns a logger, based on the class name being transformed, to which warnings or errors
concerning the class being transformed may be logged.
|
TransformMethod |
getOrCreateMethod(TransformMethodSignature signature)
Deprecated.
Locates and returns the method if declared in this class; If not,
the method is added to the class.
|
boolean |
isDeclaredMethod(TransformMethodSignature signature)
Deprecated.
Determines if the class being transformed includes a declared (not inherited) method
with the provided signature.
|
boolean |
isField(String fieldName)
Deprecated.
Returns true if the indicated name is a private instance field.
|
boolean |
isRootTransformation()
Deprecated.
Returns true if this transformation represents a root class (one that extends directly from
Object), or false if this transformation is an sub-class of another transformed class.
|
List<TransformField> |
matchFields(Predicate<TransformField> predicate)
Deprecated.
Finds all unclaimed fields matched by the provided predicate.
|
List<TransformField> |
matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
Deprecated.
Returns a sorted list of declared instance fields with the indicated annotation.
|
List<TransformMethod> |
matchMethods(Predicate<TransformMethod> predicate)
Deprecated.
Finds all methods matched by the provided predicate.
|
List<TransformMethod> |
matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
Deprecated.
Finds all methods matched by the provided predicate.
|
List<TransformField> |
matchUnclaimedFields()
Deprecated.
Matches all fields that are not claimed.
|
String |
newMemberName(String suggested)
Deprecated.
Returns the name of a new member (field or method).
|
String |
newMemberName(String prefix,
String baseName)
Deprecated.
As with
newMemberName(String) , but the suggested name is constructed from the prefix
and base name. |
Class |
toClass(String type)
Deprecated.
Converts a type name into a corresponding class (possibly, a transformed class).
|
getAnnotation
String getClassName()
String newMemberName(String suggested)
suggested
- the suggested value for the memberString newMemberName(String prefix, String baseName)
newMemberName(String)
, but the suggested name is constructed from the prefix
and base name. An
underscore will separate the prefix from the base name.prefix
- for the generated namebaseName
- a name, often of an existing field or methodList<TransformField> matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
List<TransformMethod> matchMethods(Predicate<TransformMethod> predicate)
predicate
- Used to filter the listList<TransformMethod> matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
annotationType
- Used to filter the listList<TransformField> matchFields(Predicate<TransformField> predicate)
predicate
- used for matchingTransformField getField(String fieldName)
fieldName
- of declared fieldRuntimeException
- if no such fieldList<TransformField> matchUnclaimedFields()
boolean isField(String fieldName)
TransformField createField(int modifiers, String type, String suggestedName)
modifiers
- modifiers for the field (typically, Modifier.PRIVATE
)type
- the type for the field, as a stringsuggestedName
- the desired name for the field, which may be modified (for uniqueness) when
returnedString addInjectedField(Class type, String suggestedName, Object value)
type
- the type of object to injectsuggestedName
- the suggested name for the new fieldvalue
- to be injected. This value is retained.<T> TransformField addIndirectInjectedField(Class<T> type, String suggestedName, ComponentValueProvider<T> provider)
addInjectedField(Class, String, Object)
, but instead of specifying the value,
a provider for the value is specified. In the generated class' constructor, the provider
will be passed the ComponentResources
and will return the final value; thus
each component instance will receive a matching unique instance via the provider.type
- type of value to injectsuggestedName
- suggested name for the new fieldprovider
- injected into the component to provide the valuevoid addImplementedInterface(Class interfaceClass)
interfaceClass
- the interface to be implemented by the classIllegalArgumentException
- if the interfaceClass argument does not represent an interfaceClass toClass(String type)
org.slf4j.Logger getLogger()
boolean isRootTransformation()
TransformMethod getOrCreateMethod(TransformMethodSignature signature)
signature
- identifies the method to locate, override or createboolean isDeclaredMethod(TransformMethodSignature signature)
signature
- identifies method to search forvoid addComponentEventHandler(String eventType, int minContextValues, String methodDescription, ComponentEventHandler handler)
Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent)
method.
If the handler is invoked,
the return value of the method will be overriden to true. Updates
the model to
indicate that there is a handler for the named event. Existing handlers, or super-class handlers,
are invoked first.eventType
- name of event to be handledminContextValues
- minimum number of event context values required to invoke the methodmethodDescription
- Text description of what the handler does (used with Event.setMethodDescription(String)
)handler
- the handler to invokeCopyright © 2003-2012 The Apache Software Foundation.