Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.services
Interface ClassTransformation

All Superinterfaces:
  AnnotationProvider

All Known Implementing Classes:
  BridgeClassTransformation

Deprecated. In 5.3

    public interface ClassTransformation

extends AnnotationProvider

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`.

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.

See Also:
  `PlasticClass`

Method Summary
`void` | `addComponentEventHandler(java.lang.String eventType, int minContextValues, java.lang.String methodDescription, ComponentEventHandler handler)` Deprecated. Adds advice to the `Component.dispatchComponentEvent(org.apache.tapestry5.runtime.ComponentEvent)` method.
`void` | `addImplementedInterface(java.lang.Class interfaceClass)` Deprecated. Transforms the class to implement the indicated interface.
`
`<T> TransformField`
` | `addIndirectInjectedField(java.lang.Class<T> type, java.lang.String suggestedName, ComponentValueProvider<T> provider)` Deprecated. Like `addInjectedField(Class, String, Object)`, but instead of specifying the value, a provider for the value is specified.
`java.lang.String` | `addInjectedField(java.lang.Class type, java.lang.String suggestedName, java.lang.Object value)` Deprecated. Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter.
`TransformField` | `createField(int modifiers, java.lang.String type, java.lang.String suggestedName)` Deprecated. Defines a new declared field for the class.
`java.lang.String` | `getClassName()` Deprecated. Returns the fully qualified class name of the class being transformed.
`TransformField` | `getField(java.lang.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(java.lang.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.
`java.util.List<TransformField>` | `matchFields(Predicate<TransformField> predicate)` Deprecated. Finds all unclaimed fields matched by the provided predicate.
`java.util.List<TransformField>` | `matchFieldsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)` Deprecated. Returns a sorted list of declared instance fields with the indicated annotation.
`java.util.List<TransformMethod>` | `matchMethods(Predicate<TransformMethod> predicate)` Deprecated. Finds all methods matched by the provided predicate.
`java.util.List<TransformMethod>` | `matchMethodsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)` Deprecated. Finds all methods matched by the provided predicate.
`java.util.List<TransformField>` | `matchUnclaimedFields()` Deprecated. Matches all fields that are not claimed.
`java.lang.String` | `newMemberName(java.lang.String suggested)` Deprecated. Returns the name of a new member (field or method).
`java.lang.String` | `newMemberName(java.lang.String prefix, java.lang.String baseName)` Deprecated. As with `newMemberName(String)`, but the suggested name is constructed from the prefix and base name.
`java.lang.Class` | `toClass(java.lang.String type)` Deprecated. Converts a type name into a corresponding class (possibly, a transformed class).

Methods inherited from interface org.apache.tapestry5.ioc.AnnotationProvider
`getAnnotation`

Method Detail

### getClassName

    java.lang.String getClassName()

  Deprecated.
  Returns the fully qualified class name of the class being transformed.

### newMemberName

    java.lang.String newMemberName(java.lang.String suggested)

  Deprecated.
  Returns the name of a new member (field or method). Ensures that the resulting name does not conflict with any existing member (declared by the underlying class, or inherited from a base class).

  Parameters:
    `suggested` - the suggested value for the member
  Returns:
    a unique name for the member

### newMemberName

    java.lang.String newMemberName(java.lang.String prefix,
                                   java.lang.String baseName)

  Deprecated.
  As with `newMemberName(String)`, but the suggested name is constructed from the prefix and base name. An underscore will separate the prefix from the base name.

  Parameters:
    `prefix` - for the generated name
    `baseName` - a name, often of an existing field or method
  Returns:
    a unique name

### matchFieldsWithAnnotation

    java.util.List<TransformField> matchFieldsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)

  Deprecated.
  Returns a sorted list of declared instance fields with the indicated annotation. Non-private and static fields are ignored.

  Since:
    5.2.0

### matchMethods

    java.util.List<TransformMethod> matchMethods(Predicate<TransformMethod> predicate)

  Deprecated.
  Finds all methods matched by the provided predicate.

  Parameters:
    `predicate` - Used to filter the list
  Returns:
    a list of matching methods (which may be empty) in ascending order (by method name), but descending order (by parameter count) within overrides of a single method name.

### matchMethodsWithAnnotation

    java.util.List<TransformMethod> matchMethodsWithAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)

  Deprecated.
  Finds all methods matched by the provided predicate.

  Parameters:
    `annotationType` - Used to filter the list
  Returns:
    a list of matching methods (which may be empty) in ascending order (by method name), but descending order (by parameter count) within overrides of a single method name.

### matchFields

    java.util.List<TransformField> matchFields(Predicate<TransformField> predicate)

  Deprecated.
  Finds all unclaimed fields matched by the provided predicate. Only considers instance fields. Added, removed and claimed fields are excluded.

  Parameters:
    `predicate` - used for matching
  Returns:
    sorted list of matching fields
  Since:
    5.2.0

### getField

    TransformField getField(java.lang.String fieldName)

  Deprecated.
  Locates a declared field by its field name. The field must exist.

  Parameters:
    `fieldName` - of declared field
  Returns:
    field information
  Throws:
    `java.lang.RuntimeException` - if no such field
  Since:
    5.2.0

### matchUnclaimedFields

    java.util.List<TransformField> matchUnclaimedFields()

  Deprecated.
  Matches all fields that are not claimed. This may include static fields and final fields, but will not include fields that have been added as part of the transformation.

  Returns:
    sorted list of unclaimed fields
  Since:
    5.2.0

### isField

    boolean isField(java.lang.String fieldName)

  Deprecated.
  Returns true if the indicated name is a private instance field.

  Returns:
    true if field exists

### createField

    TransformField createField(int modifiers,
                               java.lang.String type,
                               java.lang.String suggestedName)

  Deprecated.
  Defines a new declared field for the class. Suggested name may be modified to ensure uniqueness.

  Parameters:
    `modifiers` - modifiers for the field (typically, `Modifier.PRIVATE`)
    `type` - the type for the field, as a string
    `suggestedName` - the desired name for the field, which may be modified (for uniqueness) when returned
  Returns:
    new field instance

### addInjectedField

    java.lang.String addInjectedField(java.lang.Class type,
                                      java.lang.String suggestedName,
                                      java.lang.Object value)

  Deprecated.
  Defines a new protected instance variable whose initial value is provided statically, via a constructor parameter. The transformation caches the result, so calling this method repeatedly with the same type and value will return the same field name. Caching extends to the parent transformation, so that a value injected into a parent class will be available (via the protected instance variable) to subclasses. This is primarily used to inject service dependencies into components, though it has a number of other uses as well.

  Parameters:
    `type` - the type of object to inject
    `suggestedName` - the suggested name for the new field
    `value` - to be injected. This value is retained.
  Returns:
    the actual name of the injected field

### addIndirectInjectedField

    <T> TransformField addIndirectInjectedField(java.lang.Class<T> type,
                                                java.lang.String suggestedName,
                                                ComponentValueProvider<T> provider)

  Deprecated.
  Like `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.

  Parameters:
    `type` - type of value to inject
    `suggestedName` - suggested name for the new field
    `provider` - injected into the component to provide the value
  Returns:
    the actual name of the injected field
  Since:
    5.2.0

### addImplementedInterface

    void addImplementedInterface(java.lang.Class interfaceClass)

  Deprecated.
  Transforms the class to implement the indicated interface. If the class (or its super class) does not already implement the interface, then the interface is added, and default implementations of any methods of the interface are added.

  TODO: Checking that the names of methods in the interface do not conflict with the names of methods present in the (unmodified) class.

  Parameters:
    `interfaceClass` - the interface to be implemented by the class
  Throws:
    `java.lang.IllegalArgumentException` - if the interfaceClass argument does not represent an interface

### toClass

    java.lang.Class toClass(java.lang.String type)

  Deprecated.
  Converts a type name into a corresponding class (possibly, a transformed class). Primitive type names are returned as wrapper types.

### getLogger

    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.

### isRootTransformation

    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.

  Returns:
    true if root class, false if sub-class

### getOrCreateMethod

    TransformMethod getOrCreateMethod(TransformMethodSignature signature)

  Deprecated.
  Locates and returns the method if declared in this class; If not, the method is added to the class. If the method is an override of a base class method, then the method will delegate to the base class method (invoke it, return its value). If the method is entirely new, it will ignore its parameters and return a default value (null, 0 or false).

  Parameters:
    `signature` - identifies the method to locate, override or create
  Since:
    5.2.0

### isDeclaredMethod

    boolean isDeclaredMethod(TransformMethodSignature signature)

  Deprecated.
  Determines if the class being transformed includes a declared (not inherited) method with the provided signature.

  Parameters:
    `signature` - identifies method to search for
  Returns:
    true if a such a method exists
  Since:
    5.2.0

### addComponentEventHandler

    void addComponentEventHandler(java.lang.String eventType,
                                  int minContextValues,
                                  java.lang.String methodDescription,
                                  ComponentEventHandler handler)

  Deprecated.
  Adds advice to the `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.

  Parameters:
    `eventType` - name of event to be handled
    `minContextValues` - minimum number of event context values required to invoke the method
    `methodDescription` - Text description of what the handler does (used with `Event.setMethodDescription(String)`)
    `handler` - the handler to invoke
  Since:
    5.2.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.