org.andromda.core.engine
Class ModelProcessor

java.lang.Object
  extended by org.andromda.core.engine.ModelProcessor

public class ModelProcessor
extends java.lang.Object

Handles the processing of models. Facilitates Model Driven Architecture by enabling the generation of source code, configuration files, and other such artifacts from a single or multiple models.

Author:
Chad Brandon

Method Summary
protected  void filterAndSortValidationMessages(java.util.List messages, Filters constraints)
          Filters out any messages that should not be applied according to the AndroMDA configuration's constraints and sorts the resulting messages first by type (i.e.
 void initialize(Configuration configuration)
          Initializes this model processor instance with the given configuration.
protected  java.util.List loadModelIfNecessary(Model model)
          Loads the model into the repository only when necessary (the model has a timestamp later than the last timestamp of the loaded model).
static ModelProcessor newInstance()
          Creates a new instance the ModelProcessor.
protected  void printConsoleHeader()
          Prints the console header.
 ModelValidationMessage[] process(Configuration configuration)
          Re-configures this model processor from the given configuration instance (if different from that of the one passed in during the call to initialize(Configuration)), and runs the model processor.
 void setCartridgeFilter(java.lang.String namespaces)
          

Sets the current cartridge filter.

 void setFailOnValidationErrors(boolean failOnValidationErrors)
          Sets whether or not processing should fail when validation errors occur, default is true.
 void setLoggingConfigurationUri(java.lang.String loggingConfigurationUri)
          

Sets the loggingConfigurationUri for AndroMDA.

 void setModelValidation(boolean modelValidation)
          Sets whether or not model validation should occur.
 void setOutputEncoding(java.lang.String outputEncoding)
          Sets the encoding (UTF-8, ISO-8859-1, etc) for all output produced during model processing.
 void setXmlValidation(boolean xmlValidation)
          Sets xmlValidation to be true/false.
protected  boolean shouldProcess(java.lang.String namespace)
          Indicates whether or not the namespace should be processed.
 void shutdown()
          Shuts down the model processor (reclaims any resources).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static ModelProcessor newInstance()
Creates a new instance the ModelProcessor.

Returns:
the shared ModelProcessor instance.

process

public ModelValidationMessage[] process(Configuration configuration)
Re-configures this model processor from the given configuration instance (if different from that of the one passed in during the call to initialize(Configuration)), and runs the model processor.

Parameters:
configuration - the configuration from which to configure this model processor instance.
Returns:
any model validation messages collected during model processing (if model validation is enabled).

initialize

public void initialize(Configuration configuration)
Initializes this model processor instance with the given configuration. This configuration information is overridden (if changed) when calling process(Configuration)

Parameters:
configuration - the configuration instance by which to initialize this model processor instance.

loadModelIfNecessary

protected final java.util.List loadModelIfNecessary(Model model)
Loads the model into the repository only when necessary (the model has a timestamp later than the last timestamp of the loaded model).

Parameters:
model - the model to be loaded.

printConsoleHeader

protected void printConsoleHeader()
Prints the console header.


setModelValidation

public void setModelValidation(boolean modelValidation)
Sets whether or not model validation should occur. This is useful for performance reasons (i.e. if you have a large model it can significatly descrease the amount of time it takes for AndroMDA to process a model). By default this is set to true.

Parameters:
modelValidation - true/false on whether model validation should be performed or not.

setFailOnValidationErrors

public void setFailOnValidationErrors(boolean failOnValidationErrors)
Sets whether or not processing should fail when validation errors occur, default is true.

Parameters:
failOnValidationErrors - whether or not processing should fail if any validation errors are present.

shouldProcess

protected boolean shouldProcess(java.lang.String namespace)
Indicates whether or not the namespace should be processed. This is determined in conjunction with setCartridgeFilter(String). If the cartridgeFilter is not defined and the namespace is present within the configuration, then this method will ALWAYS return true.

Parameters:
namespace - the name of the namespace to check whether or not it should be processed.
Returns:
true/false on whether or not it should be processed.

setCartridgeFilter

public void setCartridgeFilter(java.lang.String namespaces)

Sets the current cartridge filter. This is a comma seperated list of namespaces (matching cartridges names) that should be processed.

If this filter is defined, then any cartridge names found in this list will be processed , while any other discovered cartridges will not be processed .

Parameters:
namespaces - a comma seperated list of the cartridge namespaces to be processed.

setOutputEncoding

public void setOutputEncoding(java.lang.String outputEncoding)
Sets the encoding (UTF-8, ISO-8859-1, etc) for all output produced during model processing.

Parameters:
outputEncoding - the encoding.

setXmlValidation

public void setXmlValidation(boolean xmlValidation)
Sets xmlValidation to be true/false. This defines whether XML resources loaded by AndroMDA (such as plugin descriptors) should be validated. Sometimes underlying parsers don't support XML Schema validation and in that case, we want to be able to turn it off.

Parameters:
xmlValidation - true/false on whether we should validate XML resources used by AndroMDA

setLoggingConfigurationUri

public void setLoggingConfigurationUri(java.lang.String loggingConfigurationUri)

Sets the loggingConfigurationUri for AndroMDA. This is the URI to an external logging configuration file. This is useful when you want to override the default logging configuration of AndroMDA.

You can retrieve the default log4j.xml contained within the org.andromda.core.commonpackage, customize it, and then specify the location of this logging file with this operation.

Parameters:
loggingConfigurationUri - the URI to the external logging configuation file.

shutdown

public void shutdown()
Shuts down the model processor (reclaims any resources).


filterAndSortValidationMessages

protected void filterAndSortValidationMessages(java.util.List messages,
                                               Filters constraints)
Filters out any messages that should not be applied according to the AndroMDA configuration's constraints and sorts the resulting messages first by type (i.e. the metafacade class) and then by the name of the model element to which the validation message applies.

Parameters:
messages - the collection of messages to sort.
constraints - any constraint filters to apply to the validation messages.


Copyright © 2003-2008 AndroMDA.org. All Rights Reserved.