org.apache.hivemind.service.impl
Class ClassFabImpl

java.lang.Object
  |
  +--org.apache.hivemind.service.impl.ClassFabImpl
All Implemented Interfaces:
ClassFab

public class ClassFabImpl
extends java.lang.Object
implements ClassFab

Implementation of ClassFab. Hides, as much as possible, the underlying library (Javassist).

Author:
Howard Lewis Ship

Constructor Summary
ClassFabImpl(CtClassSource source, javassist.CtClass ctClass)
           
 
Method Summary
 void addConstructor(java.lang.Class[] parameterTypes, java.lang.Class[] exceptions, java.lang.String body)
          Adds a constructor to the class.
 void addField(java.lang.String name, java.lang.Class type)
          Adds a new field with the given name and type.
 void addInterface(java.lang.Class interfaceClass)
          Adds the specified interface as an interface implemented by this class.
 MethodFab addMethod(int modifiers, MethodSignature ms, java.lang.String body)
          Adds a method.
 java.lang.Class createClass()
          Invoked last to create the class.
 MethodFab getMethodFab(MethodSignature ms)
          Returns a previous defined method so that it can be further enhanced (perhaps by adding additional catches, etc.).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFabImpl

public ClassFabImpl(CtClassSource source,
                    javassist.CtClass ctClass)
Method Detail

addInterface

public void addInterface(java.lang.Class interfaceClass)
Description copied from interface: ClassFab
Adds the specified interface as an interface implemented by this class.

Specified by:
addInterface in interface ClassFab

addField

public void addField(java.lang.String name,
                     java.lang.Class type)
Description copied from interface: ClassFab
Adds a new field with the given name and type. The field is added as a private field.

Specified by:
addField in interface ClassFab

addMethod

public MethodFab addMethod(int modifiers,
                           MethodSignature ms,
                           java.lang.String body)
Description copied from interface: ClassFab
Adds a method. The method is a public instance method.

Specified by:
addMethod in interface ClassFab
Parameters:
modifiers - Modifiers for the method (see Modifier).
ms - defines the name, return type, parameters and exceptions thrown
body - The body of the method.
Returns:
a method fabricator, used to add catch handlers.

getMethodFab

public MethodFab getMethodFab(MethodSignature ms)
Description copied from interface: ClassFab
Returns a previous defined method so that it can be further enhanced (perhaps by adding additional catches, etc.).

Specified by:
getMethodFab in interface ClassFab
Parameters:
ms - the signature of the method previously added
Returns:
the MethodFab for that method, or null if the method has not been added yet

addConstructor

public void addConstructor(java.lang.Class[] parameterTypes,
                           java.lang.Class[] exceptions,
                           java.lang.String body)
Description copied from interface: ClassFab
Adds a constructor to the class. The constructor will be public.

Specified by:
addConstructor in interface ClassFab
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.

createClass

public java.lang.Class createClass()
Description copied from interface: ClassFab
Invoked last to create the class. This will enforce that all abstract methods have been implemented in the (concrete) class.

Specified by:
createClass in interface ClassFab