com.bowstreet.generation
Interface GenContext


public interface GenContext

GenContext is a system object that is passed to all the GenHandlers and builders. It is used to access system information and to invoke other builders. This object has the lifetime of a regen.


Field Summary
static java.lang.String DEPTYPE_CLASS
          Dependency type for Java class
static java.lang.String DEPTYPE_FILE
          Dependency type for file
static java.lang.String DEPTYPE_MODEL
          Dependency type for another Model
static java.lang.String PHASE_CONSTRUCTION
          Initial generation phase when objects are created
static java.lang.String PHASE_EXTERNALIZE
          Generation phase for externalizing the generated pieces.
static java.lang.String PHASE_MODIFICATION
          Generation phase for doing more subtle modification on objects that were created in the first two phases
static java.lang.String PHASE_POSTCONSTRUCTION
          Generation phase for modifying objects that were created in Construction phase
static java.lang.String PHASE_PROCESS
          Generation phase for processing the abstract elements.
static java.lang.String PHASE_VALIDATION
          Generation phase for doing validation after all creating/modifying objects has completed in the first two phases
 
Method Summary
 void addDependency(java.lang.String type, java.lang.String id)
          This is used to notify the system that this builder call has an external dependency.
 void addExternalModelProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Add properties that will be stored as External Model Properties in the model source file.
 void deferBuilderCall(java.lang.String toPhase, BuilderCall builderCall)
          Called during a builder operation if the environment is not yet ready for this Builder to operate.
 java.lang.Object getAttribute(java.lang.String name)
          Get named attribute on GenContext.
 java.lang.Object getClassInstance(java.lang.String className)
          Instantiates a builder class object, given the class name.
 BuilderCall getCurrentBuilderCall()
          Get the BuilderCall which is running at the moment.
 GenContainer getGenContainer()
          Get the GenContainer under construction.
 java.lang.String getGenerationPhase()
          Which phase of Generation is currently being executed.
 ProfileData getProfileData()
          Get Profile data for this regen.
 GenerationSource getSourceModel()
          Get the original Source Model.
 BuilderCall invokeBuilder(BuilderCall parent, java.lang.String builderDefID, BuilderInputs builderInputs)
          Invoke another Builder using the builder ID.
 boolean isDesignTime()
          Check design time flag.
 BuilderInputs makeBuilderInputs()
          Create a BuilderInputs object
 void setAttribute(java.lang.String name, java.lang.Object value)
          Set named attribute on GenContext.
 

Field Detail

DEPTYPE_CLASS

static final java.lang.String DEPTYPE_CLASS
Dependency type for Java class

See Also:
Constant Field Values

DEPTYPE_FILE

static final java.lang.String DEPTYPE_FILE
Dependency type for file

See Also:
Constant Field Values

DEPTYPE_MODEL

static final java.lang.String DEPTYPE_MODEL
Dependency type for another Model

See Also:
Constant Field Values

PHASE_CONSTRUCTION

static final java.lang.String PHASE_CONSTRUCTION
Initial generation phase when objects are created

See Also:
Constant Field Values

PHASE_EXTERNALIZE

static final java.lang.String PHASE_EXTERNALIZE
Generation phase for externalizing the generated pieces. i.e. Classes, JSP files, etc. Note that this is called AFTER the Domain-specific AppExternalizer.

See Also:
Constant Field Values

PHASE_MODIFICATION

static final java.lang.String PHASE_MODIFICATION
Generation phase for doing more subtle modification on objects that were created in the first two phases

See Also:
Constant Field Values

PHASE_POSTCONSTRUCTION

static final java.lang.String PHASE_POSTCONSTRUCTION
Generation phase for modifying objects that were created in Construction phase

See Also:
Constant Field Values

PHASE_PROCESS

static final java.lang.String PHASE_PROCESS
Generation phase for processing the abstract elements. i.e. Action Lists into methods Note that this is called AFTER the Domain-specific AppProcesser

See Also:
Constant Field Values

PHASE_VALIDATION

static final java.lang.String PHASE_VALIDATION
Generation phase for doing validation after all creating/modifying objects has completed in the first two phases

See Also:
Constant Field Values
Method Detail

addDependency

void addDependency(java.lang.String type,
                   java.lang.String id)
This is used to notify the system that this builder call has an external dependency. This information is used by the Packaging functionality to aid in creating packages.

Parameters:
type - One of the DEPTYPE_x values.
id - The name of the dependency, e.g. a filename.
Example:
This adds a dependency on an external file:
    genContext.addDependency(GenContext.DEPTYPE_FILE, filename);

addExternalModelProperty

void addExternalModelProperty(java.lang.String propertyName,
                              java.lang.String propertyValue)
Add properties that will be stored as External Model Properties in the model source file. Note that this does nothing when DesignTime is false.

Parameters:
propertyName - The name of the property. May not be null.
propertyValue - The value for the property. May be null.
Example:
This is how the Web Service Enable builder sets the WebServiceEnabled property:
    genContext.addExternalModelProperty("WebServiceEnabled", "true");

deferBuilderCall

void deferBuilderCall(java.lang.String toPhase,
                      BuilderCall builderCall)
Called during a builder operation if the environment is not yet ready for this Builder to operate.

Example:
Tell the system to call this builder again during validation phase:
   String phase = genContext.getGenerationPhase();
   // call us back in VALIDATION phase, but keep going
   if (genContext.isDesignTime() && genContext.PHASE_CONSTRUCTION.equals(phase))
   {
       genContext.deferBuilderCall(genContext.PHASE_VALIDATION, builderCall);
   }

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Get named attribute on GenContext. This is primarily for use by the system and by GenHandlers.


getClassInstance

java.lang.Object getClassInstance(java.lang.String className)
Instantiates a builder class object, given the class name. Uses dynamic class loader. This is intended for use by GenHandlers and is generally not used by builder code.

Parameters:
className - The name of the class.
Returns:
An Object instance of the specified class name.

getCurrentBuilderCall

BuilderCall getCurrentBuilderCall()
Get the BuilderCall which is running at the moment. Note that if one builder invokes another, the deepest one will be returned at any time.

Returns:
the currently running builderCall

getGenContainer

GenContainer getGenContainer()
Get the GenContainer under construction. The GenContainer is primarily used by a GenHandler class and is not used by most builder classes.

Returns:
The GenContainer under construction.

getGenerationPhase

java.lang.String getGenerationPhase()
Which phase of Generation is currently being executed. See deferBuilderCall for an example.

Returns:
the name of the phase (one of the PHASE_x values).

getProfileData

ProfileData getProfileData()
Get Profile data for this regen. In general, builders do not need to have any specific support for profiling, because builder inputs are updated to reflect any profiling prior to calling the builder.

Returns:
The ProfileData being used for this generation.

getSourceModel

GenerationSource getSourceModel()
Get the original Source Model.

Returns:
The GenerationSource from which the BuilderCallList was obtained

invokeBuilder

BuilderCall invokeBuilder(BuilderCall parent,
                          java.lang.String builderDefID,
                          BuilderInputs builderInputs)
Invoke another Builder using the builder ID. Note that the preferred method of invoking another builder is to use the specific builder API class. For example, the Text builder has an associated API class of com.bowstreet.builders.webapp.api.Text.

Parameters:
parent - The builder call object for the builder which is making this call.
builderDefID - The ID of the builder to call.
builderInputs - The inputs for the builder you are calling.

isDesignTime

boolean isDesignTime()
Check design time flag.

Returns:
true if generation is being done in the Designer.

makeBuilderInputs

BuilderInputs makeBuilderInputs()
Create a BuilderInputs object

Returns:
A new BuilderInputs object which can be used to invoke another builder.

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.Object value)
Set named attribute on GenContext. This is primarily for use by the system and by GenHandlers.



Copyright © 2009 IBM. All Rights Reserved.