public abstract class AbstractCompilationContext extends AbstractContext implements ICompilationContext
DEFAULT_COMPILE_LOGGER_NAME, DEFAULT_OPTIMIZE_LOGGER_NAME
Constructor and Description |
---|
AbstractCompilationContext() |
AbstractCompilationContext(CompilationLevel compilationLevel) |
AbstractCompilationContext(IMRuleExecutionSet executionSet) |
AbstractCompilationContext(IMRuleExecutionSet executionSet,
CompilationLevel compilationLevel) |
Modifier and Type | Method and Description |
---|---|
void |
clearRegisteredAddons()
Clears all registered Addons.
|
void |
compile()
Convenience method to compile AND optimize the AbstractMRuleExecutionSet of this context with this context.
|
IExecutionContext |
convertToExecutionContext()
Allows to convert this compilation context to a "fake" execution context.
|
<A extends IAddon> |
getAddonInfo(A addon) |
List<IAddon> |
getAllAddons()
Gets all addons encountered during compilation process.
|
Set<IAddon> |
getAllUniqueAddons()
Gets all unique addons encountered during compilation process.
|
ICacheActivationResolver |
getCacheActivationResolver() |
CompilationLevel |
getCompilationLevel()
Returns requested
CompilationLevel |
String |
getDefaultLoggerName() |
Phase |
getPhase()
Returns current phase: COMPILE or OPTIMIZE.
|
Object |
getProperty(Object key)
Allows to retrieve properties shared between components during compilation process.
|
ICompilationContext |
getRootContext()
In case of sub context usage, this allows to access the root context.
|
void |
init()
INTERNAL USE ONLY: Called by rule engine to initialize and check before compilation.
|
boolean |
isCacheEnabled(String feature)
Tells if cache is enabled for a specific feature.
|
boolean |
isOptimizationEnabled()
Allows to completely disable optimization process.
|
boolean |
registerAddon(IAddon parent,
IAddon addon)
Registers any encountered
IAddon during compilation process. |
void |
registerAddonRecursively(IAddon parent,
IAddon addon)
Registers this Addon and all it's sub addons.
|
void |
removeProperty(Object key)
Allows to remove shared properties.
|
void |
setCacheActivationResolver(ICacheActivationResolver cacheActivationResolver) |
void |
setCompilationLevel(CompilationLevel compilationLevel)
CompilationLevel to use for compilation. |
void |
setLoggerName(String name)
Allows to override logger name for an execution / a compilation.
|
void |
setOptimizationEnabled(boolean optimizationEnabled)
Is optimization process enabled?
|
void |
setPhase(Phase phase)
Sets current phase: COMPILE or OPTIMIZE.
|
void |
setProperty(Object key,
Object value)
Allows to store properties to share between components during compilation process.
|
completeWrapping, getExecutionSet, getImports, getLog, getSecurityManager, getVariables, setExecutionSet
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExecutionSet, getImports, getLog, getReadBaseType, getSecurityManager, getVariables, getWriteBaseType, setExecutionSet
public AbstractCompilationContext()
public AbstractCompilationContext(CompilationLevel compilationLevel)
public AbstractCompilationContext(IMRuleExecutionSet executionSet)
public AbstractCompilationContext(IMRuleExecutionSet executionSet, CompilationLevel compilationLevel)
public void compile() throws MRuleValidationException
ICompilationContext
compile
in interface ICompilationContext
MRuleValidationException
ICompilationContext.compile()
public void init() throws MRuleValidationException
ICompilationContext
init
in interface ICompilationContext
MRuleValidationException
ICompilationContext.init()
public void setLoggerName(String name)
IContext
ICompilationContext.DEFAULT_COMPILE_LOGGER_NAME
or ICompilationContext.DEFAULT_OPTIMIZE_LOGGER_NAME
or IExecutionContext.DEFAULT_LOGGER_NAME
.setLoggerName
in interface IContext
setLoggerName
in class AbstractContext
public String getDefaultLoggerName()
getDefaultLoggerName
in class AbstractContext
ICompilationContext.DEFAULT_COMPILE_LOGGER_NAME
or ICompilationContext.DEFAULT_OPTIMIZE_LOGGER_NAME
depending on the current phase.public CompilationLevel getCompilationLevel()
ICompilationContext
CompilationLevel
getCompilationLevel
in interface ICompilationContext
ICompilationContext.getCompilationLevel()
public void setCompilationLevel(CompilationLevel compilationLevel)
ICompilationContext
CompilationLevel
to use for compilation.setCompilationLevel
in interface ICompilationContext
ICompilationContext.setCompilationLevel(CompilationLevel)
public Phase getPhase()
public void setPhase(Phase phase)
ICompilationContext
setPhase
in interface ICompilationContext
public Object getProperty(Object key)
ICompilationContext
getProperty
in interface ICompilationContext
public void setProperty(Object key, Object value)
ICompilationContext
setProperty
in interface ICompilationContext
public void removeProperty(Object key)
ICompilationContext
removeProperty
in interface ICompilationContext
public <A extends IAddon> AddonInfo getAddonInfo(A addon)
getAddonInfo
in interface ICompilationContext
public boolean registerAddon(IAddon parent, IAddon addon) throws MRuleValidationException
ICompilationContext
IAddon
during compilation process.
If this specific instance has already been registered, this method
does nothing.IAddon
has been registered,
this method creates addon info for it.IAddon
has been registered,
this method updates addon info and returns the same instance as provided.IAddon.wasRegistered(ICompilationContext, IAddon, AddonInfo)
is called at the end
of the registration if registration is successful (i.e. if Addon was not already registered).
Since 1.4.0, this method does not deduplicate anymore and so returns same instance
as provided. This behaviour might change in future version so returned value should
not be ignored.
Since 1.5.0, An instance of IAddon
is no more responsible for registering
it's own sub-addons, as it's done automatically. The registration process is no more
responsible for eventual deduplication, encapsulation, ... So the return type has been
changed to boolean instead of formerly IAddon.registerAddon
in interface ICompilationContext
parent
- Parent from which the addon was registered or [null | self] for root Addon.addon
- The addon to registered.MRuleValidationException
public void registerAddonRecursively(IAddon parent, IAddon addon) throws MRuleValidationException
ICompilationContext
PersistantProperties
.
If sub addons are declared differently (via Maps for instance) the IAddon.wasRegistered(ICompilationContext, IAddon, AddonInfo)
hook has to be implemented.registerAddonRecursively
in interface ICompilationContext
parent
- Parent from which the addon was registered or [null | self] for root Addon.addon
- The addon to registered recursively.MRuleValidationException
ICompilationContext.registerAddon(IAddon, IAddon)
public void clearRegisteredAddons()
ICompilationContext
clearRegisteredAddons
in interface ICompilationContext
public Set<IAddon> getAllUniqueAddons()
ICompilationContext
getAllUniqueAddons
in interface ICompilationContext
public List<IAddon> getAllAddons()
ICompilationContext
getAllAddons
in interface ICompilationContext
public boolean isCacheEnabled(String feature)
ICompilationContext
isCacheEnabled
in interface ICompilationContext
feature
- Feature for which to check cache activationpublic boolean isOptimizationEnabled()
ICompilationContext
isOptimizationEnabled
in interface ICompilationContext
public void setOptimizationEnabled(boolean optimizationEnabled)
ICompilationContext
setOptimizationEnabled
in interface ICompilationContext
public ICacheActivationResolver getCacheActivationResolver()
getCacheActivationResolver
in interface ICompilationContext
public void setCacheActivationResolver(ICacheActivationResolver cacheActivationResolver)
setCacheActivationResolver
in interface ICompilationContext
public IExecutionContext convertToExecutionContext()
ICompilationContext
convertToExecutionContext
in interface ICompilationContext
public ICompilationContext getRootContext()
IContext
getRootContext
in interface ICompilationContext
getRootContext
in interface IContext
getRootContext
in class AbstractContext