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.ioc.services
Interface ClassFab

All Known Implementing Classes:
  ClassFabImpl

Deprecated. In 5.3, use `PlasticProxyFactory` instead

    public interface ClassFab

Used when fabricating a new class. Represents a wrapper around the Javassist library.

The core concept of Javassist is how method bodies (as well as constructor bodies, etc.) are specified ... as a very Java-like scripting language. Details are available at the Javassist home page.

Method bodies look largely like Java. References to java classes must be fully qualified. Several special variables are used:

- `$0` first parameter, equivalent to `this` in Java code (and can't be used when creating a static method)
- `$1, $2, ...` actual parameters to the method
- `$args` all the parameters as an `Object[]`
- `$r` the return type of the method, typically used as `return ($r) ...`. `$r` is valid with method that return `void`. This also handles conversions between wrapper types and primitive types.
- `$w` conversion from primitive type to wrapper type, used as `($w) foo()` where `foo()` returns a primitive type and a wrapper type is needed

ClassFab instances are not thread safe.

ClassFab instances are created by a `ClassFactory`.

Method Summary
`void` | `addConstructor(java.lang.Class[] parameterTypes, java.lang.Class[] exceptions, java.lang.String body)` Deprecated. Adds a constructor to the class.
`void` | `addField(java.lang.String name, java.lang.Class type)` Deprecated. Adds a new field with the given name and type.
`void` | `addField(java.lang.String name, int modifiers, java.lang.Class Type)` Deprecated. Adds a new field with the provided modifiers.
`void` | `addInterface(java.lang.Class interfaceClass)` Deprecated. Adds the specified interface as an interface implemented by this class.
`void` | `addMethod(int modifiers, MethodSignature signature, java.lang.String body)` Deprecated. Adds a method.
`void` | `addNoOpMethod(MethodSignature signature)` Deprecated. Adds a public no-op method.
`void` | `addToString(java.lang.String toString)` Deprecated. Adds an implementation of toString, as a method that returns a fixed string.
`void` | `copyClassAnnotationsFromDelegate(java.lang.Class delegateClass)` Deprecated. Copies annotations from delegate class to the fabricated class.
`void` | `copyMethodAnnotationsFromDelegate(java.lang.Class serviceInterface, java.lang.Class delegateClass)` Deprecated. Copies method annotations from delegate class to the methods of the fabricated class.
`java.lang.Class` | `createClass()` Deprecated. Invoked last to create the class.
`void` | `proxyMethodsToDelegate(java.lang.Class serviceInterface, java.lang.String delegateExpression, java.lang.String toString)` Deprecated. Makes the fabricated class implement the provided service interface.

Method Detail

### addInterface

    void addInterface(java.lang.Class interfaceClass)

  Deprecated.
  Adds the specified interface as an interface implemented by this class. It is not an error to invoke this method multiple times with the same interface class (and the interface is only added once).

### addField

    void addField(java.lang.String name,
                  java.lang.Class type)

  Deprecated.
  Adds a new field with the given name and type. The field is added as a private field.

### addField

    void addField(java.lang.String name,
                  int modifiers,
                  java.lang.Class Type)

  Deprecated.
  Adds a new field with the provided modifiers.

### addMethod

    void addMethod(int modifiers,
                   MethodSignature signature,
                   java.lang.String body)

  Deprecated.
  Adds a method. The method is a public instance method.

  Parameters:
    `modifiers` - Modifiers for the method (see `Modifier`).
    `signature` - defines the name, return type, parameters and exceptions thrown
    `body` - The body of the method.
  Throws:
    `java.lang.RuntimeException` - if a method with that signature has already been added, or if there is a Javassist compilation error

### addConstructor

    void addConstructor(java.lang.Class[] parameterTypes,
                        java.lang.Class[] exceptions,
                        java.lang.String body)

  Deprecated.
  Adds a constructor to the class. The constructor will be public.

  Parameters:
    `parameterTypes` - the type of each parameter, or null if the constructor takes no parameters.
    `exceptions` - the type of each exception, or null if the constructor throws no exceptions.
    `body` - The body of the constructor.

### addToString

    void addToString(java.lang.String toString)

  Deprecated.
  Adds an implementation of toString, as a method that returns a fixed string.

### proxyMethodsToDelegate

    void proxyMethodsToDelegate(java.lang.Class serviceInterface,
                                java.lang.String delegateExpression,
                                java.lang.String toString)

  Deprecated.
  Makes the fabricated class implement the provided service interface. The interface will be added, and all methods in the interface will be delegate wrappers. If toString() is not part of the delegate interface, then an implementation will be supplied that returns the provided string. This method is used when creating objects that proxy their behavior to some other object.

  Parameters:
    `serviceInterface` - the interface to implement
    `delegateExpression` - the expression used to find the delegate on which methods should be invoked. Typically a field name, such as "_delegate", or a method to invoke, such as "_service()".
    `toString` - fixed value to be returned as the description of the resultant object

### copyClassAnnotationsFromDelegate

    void copyClassAnnotationsFromDelegate(java.lang.Class delegateClass)

  Deprecated.
  Copies annotations from delegate class to the fabricated class.

  Parameters:
    `delegateClass` - class of the delegate
  Since:
    5.2.0

### copyMethodAnnotationsFromDelegate

    void copyMethodAnnotationsFromDelegate(java.lang.Class serviceInterface,
                                           java.lang.Class delegateClass)

  Deprecated.
  Copies method annotations from delegate class to the methods of the fabricated class.

  Parameters:
    `serviceInterface` - service interface
    `delegateClass` - class of the delegate
  Since:
    5.2.0

### createClass

    java.lang.Class createClass()

  Deprecated.
  Invoked last to create the class. This will enforce that all abstract methods have been implemented in the (concrete) class.

### addNoOpMethod

    void addNoOpMethod(MethodSignature signature)

  Deprecated.
  Adds a public no-op method. The method will return null, false, or zero as per the return type (if not void).

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.