|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ClassTransformation
Contains class-specific information used when transforming a raw component class into an
executable component class.
An executable class is one that has been transformed to work within Tapestry. This includes
adding interfaces
(Component) but also transforming access to fields, based on
annotations and
naming conventions. Most of the changes are provided by different implementations of
ComponentClassTransformWorker.
org.apache.tapestry5.services.TapestryModule#contributeComponentClassTransformWorker(org.apache.tapestry5.ioc.OrderedConfiguration,
org.apache.tapestry5.ioc.ObjectLocator, InjectionProvider, ComponentClassResolver)| Method Summary | ||
|---|---|---|
void |
addCatch(TransformMethodSignature methodSignature,
String exceptionType,
String body)
Deprecated. Use TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2. |
|
void |
addComponentEventHandler(String eventType,
int minContextValues,
String methodDescription,
ComponentEventHandler handler)
Adds advice to the Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent) method. |
|
String |
addField(int modifiers,
String type,
String suggestedName)
Deprecated. Use createField(int, String, String) instead |
|
void |
addImplementedInterface(Class interfaceClass)
Transforms the class to implement the indicated interface. |
|
|
addIndirectInjectedField(Class<T> type,
String suggestedName,
ComponentValueProvider<T> provider)
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)
Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter. |
|
void |
addMethod(TransformMethodSignature signature,
String methodBody)
Deprecated. Use getOrCreateMethod(TransformMethodSignature) instead. This method is non-functional as of
Tapestry 5.2. |
|
void |
addTransformedMethod(TransformMethodSignature methodSignature,
String methodBody)
Deprecated. Use getOrCreateMethod(TransformMethodSignature) instead. This method is non-functional as of
Tapestry 5.2. |
|
void |
advise(TransformMethodSignature methodSignature,
ComponentMethodAdvice advice)
Deprecated. Use TransformMethod.addAdvice(ComponentMethodAdvice) instead |
|
void |
claimField(String fieldName,
Object tag)
Deprecated. Use TransformField.claim(Object) instead |
|
TransformField |
createField(int modifiers,
String type,
String suggestedName)
Defines a new declared field for the class. |
|
void |
extendConstructor(String statement)
Deprecated. Use methods that create or inject fields (directly or indirectly) |
|
void |
extendExistingMethod(TransformMethodSignature methodSignature,
String methodBody)
Deprecated. Use instead. This method is non-functional
as of Tapestry 5.2. |
|
void |
extendMethod(TransformMethodSignature methodSignature,
String methodBody)
Deprecated. Use TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2. |
|
List<String> |
findFields(FieldFilter filter)
Deprecated. Use matchFields(Predicate) instead |
|
List<String> |
findFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
Deprecated. Use matchFieldsWithAnnotation(Class) instead |
|
List<TransformMethodSignature> |
findMethods(MethodFilter filter)
Deprecated. Use matchMethods(Predicate) instead |
|
List<TransformMethodSignature> |
findMethodsWithAnnotation(Class<? extends Annotation> annotationClass)
Deprecated. Use matchMethodsWithAnnotation(Class) instead |
|
List<String> |
findUnclaimedFields()
Deprecated. Use matchUnclaimedFields() instead |
|
String |
getClassName()
Returns the fully qualified class name of the class being transformed. |
|
TransformField |
getField(String fieldName)
Locates a declared field by its field name. |
|
|
getFieldAnnotation(String fieldName,
Class<T> annotationClass)
Deprecated. Use AnnotationProvider.getAnnotation(Class) instead |
|
int |
getFieldModifiers(String fieldName)
Deprecated. Use TransformField.getModifiers() instead |
|
String |
getFieldType(String fieldName)
Deprecated. Use TransformField.getType() instead |
|
org.slf4j.Logger |
getLogger()
Returns a logger, based on the class name being transformed, to which warnings or errors concerning the class being transformed may be logged. |
|
|
getMethodAnnotation(TransformMethodSignature method,
Class<T> annotationClass)
Deprecated. Use AnnotationProvider.getAnnotation(Class) instead |
|
String |
getMethodIdentifier(TransformMethodSignature signature)
Deprecated. Use TransformMethod.getMethodIdentifier() instead |
|
TransformMethod |
getOrCreateMethod(TransformMethodSignature signature)
Locates and returns the method if declared in this class; If not, the method is added to the class. |
|
String |
getResourcesFieldName()
Deprecated. Obtain the resources from ComponentResourcesAware.getComponentResources() or
as passed to ComponentValueProvider.get(ComponentResources) instead |
|
void |
injectField(String fieldName,
Object value)
Deprecated. Use TransformField.inject(Object) instead |
|
boolean |
isDeclaredMethod(TransformMethodSignature signature)
Determines if the class being transformed includes a declared (not inherited) method with the provided signature. |
|
boolean |
isField(String fieldName)
Returns true if the indicated name is a private instance field. |
|
boolean |
isMethodOverride(TransformMethodSignature methodSignature)
Deprecated. Use TransformMethod.isOverride() instead |
|
boolean |
isRootTransformation()
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. |
|
void |
makeReadOnly(String fieldName)
Deprecated. Use TransformField.replaceAccess(TransformField) instead |
|
List<TransformField> |
matchFields(Predicate<TransformField> predicate)
Finds all unclaimed fields matched by the provided predicate. |
|
List<TransformField> |
matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
Returns a sorted list of declared instance fields with the indicated annotation. |
|
List<TransformMethod> |
matchMethods(Predicate<TransformMethod> predicate)
Finds all methods matched by the provided predicate. |
|
List<TransformMethod> |
matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
Finds all methods matched by the provided predicate. |
|
List<TransformField> |
matchUnclaimedFields()
Matches all fields that are not claimed. |
|
String |
newMemberName(String suggested)
Returns the name of a new member (field or method). |
|
String |
newMemberName(String prefix,
String baseName)
As with newMemberName(String), but the suggested name is constructed from the prefix
and base name. |
|
void |
prefixMethod(TransformMethodSignature methodSignature,
String methodBody)
Deprecated. Use TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2. |
|
void |
removeField(String fieldName)
Deprecated. This method is non-functional as of Tapestry 5.2 |
|
void |
replaceReadAccess(String fieldName,
String methodName)
Deprecated. Use {@link TransformField#replaceAccess(ComponentValueProvider) instead |
|
void |
replaceWriteAccess(String fieldName,
String methodName)
Deprecated. Use {@link TransformField#replaceAccess(ComponentValueProvider) instead |
|
Class |
toClass(String type)
Converts a type name into a corresponding class (possibly, a transformed class). |
|
| Methods inherited from interface org.apache.tapestry5.ioc.AnnotationProvider |
|---|
getAnnotation |
| Method Detail |
|---|
String getClassName()
String newMemberName(String suggested)
suggested - the suggested value for the member
String 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 method
List<String> findFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
matchFieldsWithAnnotation(Class) instead
List<TransformField> matchFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
List<TransformMethodSignature> findMethodsWithAnnotation(Class<? extends Annotation> annotationClass)
matchMethodsWithAnnotation(Class) instead
annotationClass -
findMethods(MethodFilter)List<TransformMethodSignature> findMethods(MethodFilter filter)
matchMethods(Predicate) instead
filter - Passed each method signature, it may include or exclude each potential
List<TransformMethod> matchMethods(Predicate<TransformMethod> predicate)
predicate - Used to filter the list
List<TransformMethod> matchMethodsWithAnnotation(Class<? extends Annotation> annotationType)
annotationType - Used to filter the list
List<String> findFields(FieldFilter filter)
matchFields(Predicate) instead
filter - passed each field name and field type
List<TransformField> matchFields(Predicate<TransformField> predicate)
predicate - used for matching
<T extends Annotation> T getFieldAnnotation(String fieldName,
Class<T> annotationClass)
AnnotationProvider.getAnnotation(Class) instead
T - constrains parameter and return value to Annotation typesfieldName - the name of the field, which must existannotationClass - the type of annotation to access
IllegalArgumentException - if the fieldName does not correspond to a declared fieldTransformField getField(String fieldName)
name - of declared field
RuntimeException - if no such field
<T extends Annotation> T getMethodAnnotation(TransformMethodSignature method,
Class<T> annotationClass)
AnnotationProvider.getAnnotation(Class) instead
T - constrains parameter and return value to Annotation typesmethod - the method signature to searchannotationClass - the type of annotation to access
IllegalArgumentException - if the method signature does not correspond to a declared method
void claimField(String fieldName,
Object tag)
TransformField.claim(Object) instead
fieldName - the name of the field that is being claimedtag - a non-null object that represents why the field is being tagged (this is typically
a specific
annotation on the field)
IllegalArgumentException - if the fieldName does not correspond to a declared instance field
IllegalStateException - if the field is already claimed for some other tagvoid makeReadOnly(String fieldName)
TransformField.replaceAccess(TransformField) instead
fieldName - name of field to so changeReadOnlyFieldValueConduitList<String> findUnclaimedFields()
matchUnclaimedFields() instead
claimField(String, Object))
and have not been added , and returns the names of those fields. May return an empty array.
List<TransformField> matchUnclaimedFields()
String getFieldType(String fieldName)
TransformField.getType() instead
fieldName -
RuntimeException - if the fieldName does not correspond to a declared instance fieldboolean isField(String fieldName)
fieldName -
String addField(int modifiers,
String type,
String suggestedName)
createField(int, String, String) instead
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
returned
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
returned
String 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.
T - type - type of value to injectsuggestedName - suggested name for the new fieldprovider - injected into the component to provide the value
void injectField(String fieldName,
Object value)
TransformField.inject(Object) instead
fieldName - name of field to convertvalue - the value provided by the fieldvoid addImplementedInterface(Class interfaceClass)
interfaceClass - the interface to be implemented by the class
IllegalArgumentException - if the interfaceClass argument does not represent an interface
void extendMethod(TransformMethodSignature methodSignature,
String methodBody)
TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2.
CtBehavior.insertAfter(java.lang.String)). To access or change
the return value, use the $_ pseudo variable.
The method may be declared in the class, or may be inherited from a super-class. For inherited methods, a method
body is added that first invokes the super implementation. Use
addMethod(TransformMethodSignature, String) when it is necessary to control when the super-class method
is invoked.
The extended method is considered new. New methods are not scanned for
removeField(String) removed}, replaceReadAccess(String, String) read replaced}, or
write replaced fields. Generally that's what you want!
methodSignature - the signature of the method to extendmethodBody - the body of code
MethodCompileException - if the provided Javassist method body can not be compiled
void extendExistingMethod(TransformMethodSignature methodSignature,
String methodBody)
instead. This method is non-functional
as of Tapestry 5.2.
extendMethod(TransformMethodSignature, String), but the extension does not mark
the method as new,
and field changes will be processed. Note: at some point, this is not longer true; extend and
extendMethod work identically.
methodSignature - signature of the method to extendmethodBody - the body of code
MethodCompileException - if the provided method body can not be compiledprefixMethod(TransformMethodSignature, String)
void prefixMethod(TransformMethodSignature methodSignature,
String methodBody)
TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2.
CtBehavior.insertBefore(String).
The method may be declared in the class, or may be inherited from a super-class. For inherited methods, a method
is added that first invokes the super implementation. Use addMethod(TransformMethodSignature, String)
when it is necessary to control when the super-class method is invoked.
Like extendExistingMethod(TransformMethodSignature, String), this method is generally used to "wrap" an
existing method adding additional functionality such as caching or transaction support.
methodSignature - methodBody -
MethodCompileException - if the provided method body can not be compiledString getResourcesFieldName()
ComponentResourcesAware.getComponentResources() or
as passed to ComponentValueProvider.get(ComponentResources) instead
ComponentResources for the transformed
component. This will be a protected field, accessible to the class and subclasses.
void addMethod(TransformMethodSignature signature,
String methodBody)
getOrCreateMethod(TransformMethodSignature) instead. This method is non-functional as of
Tapestry 5.2.
extendMethod(TransformMethodSignature, String),
or you should
remember to invoke the super class implemetation explicitly. Use this method to control when
the super-class
implementation is invoked.
void addTransformedMethod(TransformMethodSignature methodSignature,
String methodBody)
getOrCreateMethod(TransformMethodSignature) instead. This method is non-functional as of
Tapestry 5.2.
addMethod(TransformMethodSignature, String), but field references inside the
method will be transformed, and the method must not already exist.
void extendConstructor(String statement)
statement - the statement to add, which should end with a semicolonComponentValueProvider
void replaceReadAccess(String fieldName,
String methodName)
addMethod(TransformMethodSignature, String) or
extendMethod(TransformMethodSignature, String).
void replaceWriteAccess(String fieldName,
String methodName)
addMethod(TransformMethodSignature, String) or
extendMethod(TransformMethodSignature, String).
void removeField(String fieldName)
fieldName - the name of the field to removereplaceReadAccess(String, String),
replaceWriteAccess(String, String)Class toClass(String type)
org.slf4j.Logger getLogger()
int getFieldModifiers(String fieldName)
TransformField.getModifiers() instead
String getMethodIdentifier(TransformMethodSignature signature)
TransformMethod.getMethodIdentifier() instead
TransformMethodSignature.getMediumDescription() appended with source file information
and line number
information (when available).
signature -
boolean isRootTransformation()
void addCatch(TransformMethodSignature methodSignature,
String exceptionType,
String body)
TransformMethod.addAdvice(ComponentMethodAdvice) instead. This method is non-functional
as of Tapestry 5.2.
methodSignature - method to be extended.exceptionType - fully qualified class name of exceptionbody - code to execute
void advise(TransformMethodSignature methodSignature,
ComponentMethodAdvice advice)
TransformMethod.addAdvice(ComponentMethodAdvice) instead
boolean isMethodOverride(TransformMethodSignature methodSignature)
TransformMethod.isOverride() instead
methodSignature - signature of method to check
TransformMethod getOrCreateMethod(TransformMethodSignature signature)
signature - identifies the method to locate, override or createboolean isDeclaredMethod(TransformMethodSignature signature)
signature - identifies method to search for
void 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 invoke
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||