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:

ClassFab instances are not thread safe.

ClassFab instances are created by a ClassFactory.


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

Method Detail

addInterface

void addInterface(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(String name,
              Class type)
Deprecated. 
Adds a new field with the given name and type. The field is added as a private field.


addField

void addField(String name,
              int modifiers,
              Class Type)
Deprecated. 
Adds a new field with the provided modifiers.


addMethod

void addMethod(int modifiers,
               MethodSignature signature,
               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:
RuntimeException - if a method with that signature has already been added, or if there is a Javassist compilation error

addConstructor

void addConstructor(Class[] parameterTypes,
                    Class[] exceptions,
                    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(String toString)
Deprecated. 
Adds an implementation of toString, as a method that returns a fixed string.


proxyMethodsToDelegate

void proxyMethodsToDelegate(Class serviceInterface,
                            String delegateExpression,
                            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(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(Class serviceInterface,
                                       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

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



Copyright © 2003-2012 The Apache Software Foundation.