Class AbstractWorkbenchDelegate<WorkflowConfigurationType extends AbstractJobConfiguration,WorkflowType extends Workflow>
- java.lang.Object
-
- de.uka.ipd.sdq.workflow.workbench.AbstractWorkbenchDelegate<WorkflowConfigurationType,WorkflowType>
-
- Type Parameters:
WorkflowConfigurationType
- The type of the configuration object needed by the workflow job to configure itself. Out of the box support for the run mode (run or debug), log-level, and unit test runs is provided.WorkflowType
- The type of the workflow to be executed. This can be simple workflows, workflows using a blackboard, etc.
- All Implemented Interfaces:
IActionDelegate
- Direct Known Subclasses:
AbstractMDSDWorkbenchDelegate
public abstract class AbstractWorkbenchDelegate<WorkflowConfigurationType extends AbstractJobConfiguration,WorkflowType extends Workflow> extends Object implements IActionDelegate
Abstract base class for Eclipse Workbench Actions which run based on the Palladio workflow engine, i.e., the run has an IJob which gets executed. The class offers features to support logging into the Eclipse console, support for an Eclipse process which can be used to interrupt, terminate or debug the run, integration of the Eclipse progress bar, exception handling, etc. * The class is abstract and defines some methods, which must be implemented by subclasses. See method descriptions for details. This class is based on code provided by Roman Andrej
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
DETAILED_LOG_PATTERN
Log Pattern used for debug mode.protected static String
SHORT_LOG_PATTERN
Log Pattern used for run mode.static String
VERBOSE_LOGGING
Name of the entry in the configuration hashmap containing the log level.protected List<WorkflowStatusListener>
workflowListener
A list of listeners to inform about workflow status changes.
-
Constructor Summary
Constructors Constructor Description AbstractWorkbenchDelegate()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected WorkflowExceptionHandler
createExceptionHandler(boolean interactive)
Instanciate the workflow exception handler used to handle failures in the workflow.protected WorkflowType
createWorkflow(WorkflowConfigurationType workflowConfiguration)
Instantiate the workflow engine.protected abstract IJob
createWorkflowJob(WorkflowConfigurationType config)
Instantiate the main job to be executed by the workflow engine.protected abstract WorkflowConfigurationType
getConfiguration()
This method is called as template method and has to be overriden by clients.protected org.apache.log4j.Level
getLogLevel()
Get the log level based on the extended CommonTab in DebugEnabledCommonTab.protected WorkflowProcess
getProcess()
Instantiate the Eclipse process used by the workflow engine.List<WorkflowStatusListener>
getWorkflowListener()
Access the list of registered workflow status listeners.void
register(WorkflowStatusListener listner)
Register a workflow status listener to the delegate.void
run(IAction action)
void
setProgressMonitor(IProgressMonitor progressMonitor)
Set another progress monitor the workflow should report to than the default null progress one.protected LoggerAppenderStruct
setupLogger(String loggerName, org.apache.log4j.Level logLevel, String layout)
Configure the named LOGGER to log on the given log level with the given PatternLayout.protected ArrayList<LoggerAppenderStruct>
setupLogging(org.apache.log4j.Level logLevel)
Setup LOGGER for the workflow run.protected abstract boolean
useSeparateConsoleForEachJobRun()
Use separate console for each job run.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.ui.IActionDelegate
selectionChanged
-
-
-
-
Field Detail
-
SHORT_LOG_PATTERN
protected static final String SHORT_LOG_PATTERN
Log Pattern used for run mode.- See Also:
- Constant Field Values
-
DETAILED_LOG_PATTERN
protected static final String DETAILED_LOG_PATTERN
Log Pattern used for debug mode.- See Also:
- Constant Field Values
-
VERBOSE_LOGGING
public static final String VERBOSE_LOGGING
Name of the entry in the configuration hashmap containing the log level.- See Also:
- Constant Field Values
-
workflowListener
protected final List<WorkflowStatusListener> workflowListener
A list of listeners to inform about workflow status changes.
-
-
Method Detail
-
run
public void run(IAction action)
- Specified by:
run
in interfaceIActionDelegate
-
getLogLevel
protected org.apache.log4j.Level getLogLevel()
Get the log level based on the extended CommonTab in DebugEnabledCommonTab.TODO: Anne has set this to protected because the logging has to be re-enabled during PerOpteryx. Check later whether there is a better solution.
- Returns:
- The log level selected by the user
-
createExceptionHandler
protected WorkflowExceptionHandler createExceptionHandler(boolean interactive)
Instanciate the workflow exception handler used to handle failures in the workflow. By default returns an excpetion handler which uses Eclipse Dialogs to inform the user about the failure.- Parameters:
interactive
- Whether the workflow runs interactive- Returns:
- A workflow exception handler
-
createWorkflow
protected WorkflowType createWorkflow(WorkflowConfigurationType workflowConfiguration)
Instantiate the workflow engine. By default a standard workflow engine is created.- Parameters:
workflowConfiguration
- Configuration of the workflow job- Returns:
- The workflow engine to use for this launch
-
setupLogging
protected ArrayList<LoggerAppenderStruct> setupLogging(org.apache.log4j.Level logLevel)
Setup LOGGER for the workflow run. May be overridden by clients to configure further LOGGER for other namespaces than de.uka.ipd.sdq.workflow. Use protected method setupLogger to configure additional loggers- Parameters:
logLevel
- The apache log4j log level requested by the user as log level- Returns:
- the array list
-
setupLogger
protected LoggerAppenderStruct setupLogger(String loggerName, org.apache.log4j.Level logLevel, String layout)
Configure the named LOGGER to log on the given log level with the given PatternLayout.- Parameters:
loggerName
- The name of the LOGGER to configurelogLevel
- The log level to be used by the LOGGER to configurelayout
- The layout for the pattern layout to be used to format log messages. The layout may reuse the defined constants in this class for short and detailed log outputs- Returns:
- the LOGGER appender struct
-
getProcess
protected WorkflowProcess getProcess()
Instantiate the Eclipse process used by the workflow engine. Override this method to return a different process if you need support for debugging, etc.- Returns:
- The process used to execute this launch
-
getWorkflowListener
public List<WorkflowStatusListener> getWorkflowListener()
Access the list of registered workflow status listeners.- Returns:
- The currently registered listeners
-
register
public void register(WorkflowStatusListener listner)
Register a workflow status listener to the delegate.- Parameters:
listner
- The listener to register.
-
setProgressMonitor
public void setProgressMonitor(IProgressMonitor progressMonitor)
Set another progress monitor the workflow should report to than the default null progress one. Note: The progress monitor must be set before the workflow is triggered! (run method)- Parameters:
progressMonitor
- The monitor to report to.
-
createWorkflowJob
protected abstract IJob createWorkflowJob(WorkflowConfigurationType config)
Instantiate the main job to be executed by the workflow engine. The job can be a single job or any other job type like composite jobs. The job will be run by the workflow engine.- Parameters:
config
- The strongly-typed configuration object used to configure the main workflow job- Returns:
- The main workflow job to be executed by the workflow engine
-
useSeparateConsoleForEachJobRun
protected abstract boolean useSeparateConsoleForEachJobRun()
Use separate console for each job run.- Returns:
- true, if successful
-
getConfiguration
protected abstract WorkflowConfigurationType getConfiguration()
This method is called as template method and has to be overriden by clients. Its purpose is to return a strongly typed configuration object needed by this workflow's main workflow job.- Returns:
- The strongly typed configuration object for the main workflow job
-
-