org.codehaus.jam.provider
Class JamClassBuilder

java.lang.Object
  extended by org.codehaus.jam.provider.JamClassBuilder
Direct Known Subclasses:
CompositeJamClassBuilder

public abstract class JamClassBuilder
extends java.lang.Object

Implemented by providers to build and initialize classes on demand. The main responsibility a JAM provider has is writing an extension of this class.

Author:
Patrick Calahan <email: pcal-at-bea-dot-com>

Constructor Summary
JamClassBuilder()
           
 
Method Summary
protected  void assertInitialized()
          Asserts that init() has been called on this class builder.
abstract  MClass build(java.lang.String packageName, java.lang.String className)
          This is called by JAM when it attempts to load a class.
protected  MClass createClassToBuild(java.lang.String packageName, java.lang.String className, java.lang.String[] importSpecs)
          When a JamClassBuilder decides that it is going to be able to respond to a build() request, it must call this method to get an initial instance of MClass to return.
protected  MClass createClassToBuild(java.lang.String packageName, java.lang.String className, java.lang.String[] importSpecs, JamClassPopulator pop)
          When a JamClassBuilder decides that it is going to be able to respond to a build() request, it must call this method to get an initial instance of MClass to return.
protected  JamLogger getLogger()
           
 void init(ElementContext ctx)
          This method is called by JAM to initialize this class builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JamClassBuilder

public JamClassBuilder()
Method Detail

init

public void init(ElementContext ctx)
This method is called by JAM to initialize this class builder. Extending classes can override this to perform additional initialization work (just remember to call super.init()!).

Parameters:
ctx -

build

public abstract MClass build(java.lang.String packageName,
                             java.lang.String className)

This is called by JAM when it attempts to load a class. If the builder has access to an artifact (typically a java source or classfile) that represents the given type, it should call createClassToBuild() to get a new instance of MClass and then return it. No caching should be performed - if an MClass is going to be returned, it should be a new instance returned by createClassToBuild()

If no artififact is available, the builder should just return null, signalling that other JamClassBuilders should attempt to build the class.

Parameters:
packageName -
className -
Returns:

createClassToBuild

protected MClass createClassToBuild(java.lang.String packageName,
                                    java.lang.String className,
                                    java.lang.String[] importSpecs,
                                    JamClassPopulator pop)

When a JamClassBuilder decides that it is going to be able to respond to a build() request, it must call this method to get an initial instance of MClass to return.

Parameters:
packageName - qualified name of the package that contains the class to create
className - simple name of the class to create.
importSpecs - array of import specs to be used in the class, or null if not known or relevant. Import specs are only strictly required if the builder is planning on setting any unqualified type references on the class. The importspec values will be used in determining what is retuned by JClass.getImportedPackages() and getImportedClasses(). Note that an importSpec does not include the word 'import' - e.g. it should only be 'java.util.List' or 'java.util.*'

createClassToBuild

protected MClass createClassToBuild(java.lang.String packageName,
                                    java.lang.String className,
                                    java.lang.String[] importSpecs)

When a JamClassBuilder decides that it is going to be able to respond to a build() request, it must call this method to get an initial instance of MClass to return.

Parameters:
packageName - qualified name of the package that contains the class to create
className - simple name of the class to create.
importSpecs - array of import specs to be used in the class, or null if not known or relevant. Import specs are only needed if the builder is planning on setting any unqualified type references on the class.

getLogger

protected JamLogger getLogger()

assertInitialized

protected final void assertInitialized()
Asserts that init() has been called on this class builder.