public class ClassFabImpl extends AbstractFab implements ClassFab
ClassFab
. Hides, as much as possible, the underlying
library (Javassist).lock
Constructor and Description |
---|
ClassFabImpl(CtClassSource source,
javassist.CtClass ctClass,
org.slf4j.Logger logger) |
Modifier and Type | Method and Description |
---|---|
void |
addConstructor(Class[] parameterTypes,
Class[] exceptions,
String body)
Adds a constructor to the class.
|
void |
addField(String name,
Class type)
Adds a new field with the given name and type.
|
void |
addField(String name,
int modifiers,
Class type)
Adds a new field with the provided modifiers.
|
void |
addMethod(int modifiers,
MethodSignature ms,
String body)
Adds a method.
|
void |
addNoOpMethod(MethodSignature signature)
Adds a public no-op method.
|
void |
addToString(String toString)
Adds an implementation of toString, as a method that returns a fixed string.
|
void |
copyClassAnnotationsFromDelegate(Class delegateClass)
Copies annotations from delegate class to the fabricated class.
|
void |
copyMethodAnnotationsFromDelegate(Class serviceInterface,
Class delegateClass)
Copies method annotations from delegate class to the methods of the fabricated class.
|
void |
proxyMethodsToDelegate(Class serviceInterface,
String delegateExpression,
String toString)
Makes the fabricated class implement the provided service interface.
|
String |
toString()
Returns a representation of the fabricated class, including inheritance, fields, constructors, methods and method
bodies.
|
addInterface, createClass, getCtClass, getLogger, getSource, toCtClass, toCtClasses
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addInterface, createClass
public ClassFabImpl(CtClassSource source, javassist.CtClass ctClass, org.slf4j.Logger logger)
public String toString()
public void addField(String name, Class type)
ClassFab
public void addField(String name, int modifiers, Class type)
ClassFab
public void proxyMethodsToDelegate(Class serviceInterface, String delegateExpression, String toString)
ClassFab
proxyMethodsToDelegate
in interface ClassFab
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 objectpublic void addToString(String toString)
ClassFab
addToString
in interface ClassFab
public void addMethod(int modifiers, MethodSignature ms, String body)
ClassFab
public void addNoOpMethod(MethodSignature signature)
ClassFab
addNoOpMethod
in interface ClassFab
public void addConstructor(Class[] parameterTypes, Class[] exceptions, String body)
ClassFab
addConstructor
in interface ClassFab
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.public void copyClassAnnotationsFromDelegate(Class delegateClass)
ClassFab
copyClassAnnotationsFromDelegate
in interface ClassFab
delegateClass
- class of the delegatepublic void copyMethodAnnotationsFromDelegate(Class serviceInterface, Class delegateClass)
ClassFab
copyMethodAnnotationsFromDelegate
in interface ClassFab
serviceInterface
- service interfacedelegateClass
- class of the delegateCopyright © 2003-2012 The Apache Software Foundation.