|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
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
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 |
|---|
void addInterface(Class interfaceClass)
void addField(String name,
Class type)
void addField(String name,
int modifiers,
Class Type)
void addMethod(int modifiers,
MethodSignature signature,
String body)
modifiers - Modifiers for the method (see Modifier).signature - defines the name, return type, parameters and exceptions thrownbody - The body of the method.
RuntimeException - if a method with that signature has already been added, or if there is a Javassist
compilation error
void addConstructor(Class[] parameterTypes,
Class[] exceptions,
String body)
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.void addToString(String toString)
void proxyMethodsToDelegate(Class serviceInterface,
String delegateExpression,
String toString)
serviceInterface - the interface to implementdelegateExpression - 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 objectvoid copyClassAnnotationsFromDelegate(Class delegateClass)
delegateClass - class of the delegate
void copyMethodAnnotationsFromDelegate(Class serviceInterface,
Class delegateClass)
serviceInterface - service interfacedelegateClass - class of the delegateClass createClass()
void addNoOpMethod(MethodSignature signature)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||