Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.hivemind.service
Interface ClassFab  view ClassFab download ClassFab.java


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. The BodyBuilder class is very useful for assembling this method bodies. 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:


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 signature, java.lang.String body)
          Adds a method.
 boolean containsMethod(MethodSignature signature)
          Convenience method for checking whether the fabricated class already contains a method.
 java.lang.Class createClass()
          Invoked last to create the class.
 MethodFab getMethodFab(MethodSignature signature)
          Returns a previous defined method so that it can be further enhanced (perhaps by adding additional catches, etc.).
 

Method Detail

addInterface

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


addField

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


containsMethod

public boolean containsMethod(MethodSignature signature)
Convenience method for checking whether the fabricated class already contains a method.


addMethod

public MethodFab addMethod(int modifiers,
                           MethodSignature signature,
                           java.lang.String body)
Adds a method. The method is a public instance method.


getMethodFab

public MethodFab getMethodFab(MethodSignature signature)
Returns a previous defined method so that it can be further enhanced (perhaps by adding additional catches, etc.).


addConstructor

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


createClass

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