Class TracerFactory
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.execution.TracerFactory
-
- Direct Known Subclasses:
ConsoleTracerFactory,GuiTracerFactory,TracerFactory.DefaultTracerFactory
public abstract class TracerFactory extends java.lang.ObjectA factory for the VIL language execution tracers. Basically, default tracer factory (getDefaultInstance()) is static and initialized withDEFAULT. However, as VIL can be executed in multiple threads in parallel, this factory can also be used on a per-thread basis (getInstance().- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTracerFactory.DefaultTracerFactoryThe default tracer factory returning tracer instances which do not trace anything (NoTracer).private static classTracerFactory.TaskDataStores information about the current task of a progress observer.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.Thread,ITracer>BUILDLANG_TRACERSstatic TracerFactoryDEFAULTDefines the default tracer.private static TracerFactorydefaultFactorystatic IInstantiatorTracerEMPTY_INSTANTIATOR_TRACERprivate static ITraceFilterfilterprivate static java.util.Map<java.lang.Long,TracerFactory>instancesstatic java.util.Map<ProgressObserver,TracerFactory.TaskData>PROGRESS_OBSERVERSstatic java.util.Map<java.lang.Thread,ITracer>TEMPLATELANG_TRACERS
-
Constructor Summary
Constructors Constructor Description TracerFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static voidcloseTasks(java.lang.String description)Closes existing tasks with the givendescriptionon all registered observers.static ITracercreateBuildLanguageTracer()Creates a tracer for the VIL build language.abstract ITracercreateBuildLanguageTracerImpl()Creates a tracer for the VIL build language.static IInstantiatorTracercreateInstantiatorTracer()Creates a tracer for instantiators.abstract IInstantiatorTracercreateInstantiatorTracerImpl()Creates a tracer for instantiators, i.e., to send messages to the VIL output.static ITracercreateTemplateLanguageTracer()Creates a tracer for the VIL template language.abstract ITracercreateTemplateLanguageTracerImpl()Creates a tracer for the VIL template language.static voidensureTasks(java.lang.String description)Ensures that there is a task with the givendescriptionon all registered observers.static TracerFactorygetDefaultInstance()Returns the default instance.static TracerFactorygetInstance()Returns the tracer factory for the current thread.static ITracergetRegisteredBuildLanguageTracer()Returns the currently registered build language tracer for the current thread.static ITracergetRegisteredTemplateLanguageTracer()Returns the currently registered template language tracer for the current thread.static ITraceFiltergetTraceFilter()static voidprogress(int actual, int max, java.lang.String description)Notifies the tracer about the actual progress in order to inform the user.static voidprogressSubTask(int actual, int max, java.lang.String taskName)Notifies about creation/progress of a subtask (just grabbing the actual task in all registered observers).static voidregisterBuildLanguageTracer(ITracer tracer)Registers a build language tracer along with the current thread.static voidregisterProgressObserver(ProgressObserver observer)Registers the given progress reserver.static voidregisterTemplateLanguageTracer(ITracer tracer)Registers a template language tracer along with the current thread.static voidsetDefaultInstance(TracerFactory factory)Defines the default instance.static voidsetInstance(TracerFactory newInstance)Defines a new tracer factory for the current thread.static ITraceFiltersetTraceFilter(ITraceFilter fInstance)Defines the trace filter to applied on all created tracers.static voidunregisterBuildLanguageTracer(ITracer tracer)Unregisters a build language tracer from the current thread.static voidunregisterProgressObserver(ProgressObserver observer)Unregisters the given progress observer.static voidunregisterTemplateLanguageTracer(ITracer tracer)Unregisters a template language tracer from the current thread.
-
-
-
Field Detail
-
DEFAULT
public static final TracerFactory DEFAULT
Defines the default tracer.
-
TEMPLATELANG_TRACERS
public static final java.util.Map<java.lang.Thread,ITracer> TEMPLATELANG_TRACERS
-
BUILDLANG_TRACERS
public static final java.util.Map<java.lang.Thread,ITracer> BUILDLANG_TRACERS
-
PROGRESS_OBSERVERS
public static final java.util.Map<ProgressObserver,TracerFactory.TaskData> PROGRESS_OBSERVERS
-
EMPTY_INSTANTIATOR_TRACER
public static final IInstantiatorTracer EMPTY_INSTANTIATOR_TRACER
-
defaultFactory
private static TracerFactory defaultFactory
-
instances
private static java.util.Map<java.lang.Long,TracerFactory> instances
-
filter
private static ITraceFilter filter
-
-
Method Detail
-
getDefaultInstance
public static TracerFactory getDefaultInstance()
Returns the default instance.- Returns:
- the default instance
-
setDefaultInstance
public static void setDefaultInstance(TracerFactory factory)
Defines the default instance.- Parameters:
factory- the new default instance (ignored if null)
-
setInstance
public static void setInstance(TracerFactory newInstance)
Defines a new tracer factory for the current thread.- Parameters:
newInstance- the new tracer factory (null deletes a previously defined instance)
-
getInstance
public static TracerFactory getInstance()
Returns the tracer factory for the current thread.- Returns:
- the current tracer factory, if there is none defined return
defaultFactory
-
setTraceFilter
public static ITraceFilter setTraceFilter(ITraceFilter fInstance)
Defines the trace filter to applied on all created tracers.- Parameters:
fInstance- the new trace filter, ignored if null- Returns:
- the filter before this call, may be null
-
getTraceFilter
public static ITraceFilter getTraceFilter()
-
createTemplateLanguageTracerImpl
public abstract ITracer createTemplateLanguageTracerImpl()
Creates a tracer for the VIL template language.- Returns:
- a tracer instance for the VIL template language (null will lead to the
corresponding result by
DEFAULT)
-
createBuildLanguageTracerImpl
public abstract ITracer createBuildLanguageTracerImpl()
Creates a tracer for the VIL build language.- Returns:
- a tracer instance for the VIL build language (null will lead to the
corresponding result by
DEFAULT)
-
createInstantiatorTracerImpl
public abstract IInstantiatorTracer createInstantiatorTracerImpl()
Creates a tracer for instantiators, i.e., to send messages to the VIL output.- Returns:
- the instantiator tracer
-
createTemplateLanguageTracer
public static ITracer createTemplateLanguageTracer()
Creates a tracer for the VIL template language.- Returns:
- a tracer instance for the VIL template language
-
createBuildLanguageTracer
public static ITracer createBuildLanguageTracer()
Creates a tracer for the VIL build language.- Returns:
- a tracer instance for the VIL build language
-
createInstantiatorTracer
public static IInstantiatorTracer createInstantiatorTracer()
Creates a tracer for instantiators.- Returns:
- a tracer for instantiators
-
registerBuildLanguageTracer
public static void registerBuildLanguageTracer(ITracer tracer)
Registers a build language tracer along with the current thread.- Parameters:
tracer- the tracer, ignored if null- See Also:
unregisterBuildLanguageTracer(net.ssehub.easy.instantiation.core.model.buildlangModel.ITracer)
-
unregisterBuildLanguageTracer
public static void unregisterBuildLanguageTracer(ITracer tracer)
Unregisters a build language tracer from the current thread.- Parameters:
tracer- the tracer, ignored if null- See Also:
registerBuildLanguageTracer(net.ssehub.easy.instantiation.core.model.buildlangModel.ITracer)
-
getRegisteredBuildLanguageTracer
public static ITracer getRegisteredBuildLanguageTracer()
Returns the currently registered build language tracer for the current thread.- Returns:
- the currently registered build language tracer or null if there is none
-
registerTemplateLanguageTracer
public static void registerTemplateLanguageTracer(ITracer tracer)
Registers a template language tracer along with the current thread.- Parameters:
tracer- the tracer, ignored if null- See Also:
unregisterTemplateLanguageTracer(net.ssehub.easy.instantiation.core.model.templateModel.ITracer)
-
unregisterTemplateLanguageTracer
public static void unregisterTemplateLanguageTracer(ITracer tracer)
Unregisters a template language tracer from the current thread.- Parameters:
tracer- the tracer, ignored if null- See Also:
registerTemplateLanguageTracer(net.ssehub.easy.instantiation.core.model.templateModel.ITracer)
-
getRegisteredTemplateLanguageTracer
public static ITracer getRegisteredTemplateLanguageTracer()
Returns the currently registered template language tracer for the current thread.- Returns:
- the currently registered template language tracer or null if there is none
-
progress
public static void progress(int actual, int max, java.lang.String description)Notifies the tracer about the actual progress in order to inform the user.- Parameters:
actual- the actual step (negative disables display)max- the maximum number of steps (may vary over time, negative disables display)description- an optional description of the step (may be null)
-
progressSubTask
public static void progressSubTask(int actual, int max, java.lang.String taskName)Notifies about creation/progress of a subtask (just grabbing the actual task in all registered observers).- Parameters:
actual- the actual number of steps in the sub taskmax- the maximum number of stepstaskName- the name of the sub task
-
ensureTasks
public static void ensureTasks(java.lang.String description)
Ensures that there is a task with the givendescriptionon all registered observers. Existing tasks will be kept.- Parameters:
description- the task description
-
closeTasks
public static void closeTasks(java.lang.String description)
Closes existing tasks with the givendescriptionon all registered observers. Closed tasks will be set to null on the respective observers.- Parameters:
description- the description to look for
-
registerProgressObserver
public static void registerProgressObserver(ProgressObserver observer)
Registers the given progress reserver.- Parameters:
observer- the observer (ignored if null)
-
unregisterProgressObserver
public static void unregisterProgressObserver(ProgressObserver observer)
Unregisters the given progress observer.- Parameters:
observer- the progress observer (ignored if null)
-
-