public class MExecutionContextConverter extends Object implements ICompilationContext
ICompilationContext
in order to simulate an Execution context.DEFAULT_COMPILE_LOGGER_NAME, DEFAULT_OPTIMIZE_LOGGER_NAME
Constructor and Description |
---|
MExecutionContextConverter(IExecutionContext c,
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 |
IMRuleExecutionSet |
getExecutionSet() |
MBeanUtils.ImportHolder |
getImports()
Returns local imports for this context's ruleset.
|
Log |
getLog()
Get logger/
|
Phase |
getPhase()
Returns:
Phase.COMPILE or Phase.OPTIMIZE for ICompilationContext
Phase.EXECUTE for IExecutionContext
|
Object |
getProperty(Object key)
Allows to retrieve properties shared between components during compilation process.
|
Class<?> |
getReadBaseType()
Returns base object type for property read access.
|
ICompilationContext |
getRootContext()
In case of sub context usage, this allows to access the root context.
|
<T extends IMRulesSecurityManager> |
getSecurityManager(Class<T> managerClass)
Searches in security managers the one corresponding to the provided identifying class.
|
TypedMap |
getVariables()
Returns a Map of:
variables types encountered during compilation.
|
Class<?> |
getWriteBaseType()
Returns base object type for property write access.
|
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 |
setExecutionSet(IMRuleExecutionSet executionSet) |
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.
|
public MExecutionContextConverter(IExecutionContext c, CompilationLevel compilationLevel)
public void setPhase(Phase phase)
ICompilationContext
setPhase
in interface ICompilationContext
public Class<?> getReadBaseType()
IContext
getReadBaseType
in interface IContext
public Class<?> getWriteBaseType()
IContext
getWriteBaseType
in interface IContext
public TypedMap getVariables()
IContext
getVariables
in interface IContext
public MBeanUtils.ImportHolder getImports()
IContext
getImports
in interface IContext
public <T extends IMRulesSecurityManager> T getSecurityManager(Class<T> managerClass) throws MRulesSecurityException
IContext
getSecurityManager
in interface IContext
MRulesSecurityException
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
public void compile() throws MRuleValidationException
ICompilationContext
compile
in interface ICompilationContext
MRuleValidationException
public void init() throws MRuleValidationException
ICompilationContext
init
in interface ICompilationContext
MRuleValidationException
public CompilationLevel getCompilationLevel()
ICompilationContext
CompilationLevel
getCompilationLevel
in interface ICompilationContext
public void setCompilationLevel(CompilationLevel compilationLevel)
ICompilationContext
CompilationLevel
to use for compilation.setCompilationLevel
in interface ICompilationContext
public <A extends IAddon> AddonInfo getAddonInfo(A addon)
getAddonInfo
in interface ICompilationContext
public boolean registerAddon(IAddon parent, IAddon addon)
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.public void registerAddonRecursively(IAddon parent, IAddon addon)
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.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 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 ICacheActivationResolver getCacheActivationResolver()
getCacheActivationResolver
in interface ICompilationContext
public void setCacheActivationResolver(ICacheActivationResolver cacheActivationResolver)
setCacheActivationResolver
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 IExecutionContext convertToExecutionContext()
ICompilationContext
convertToExecutionContext
in interface ICompilationContext
public IMRuleExecutionSet getExecutionSet()
getExecutionSet
in interface IContext
IContext.getExecutionSet()
public void setExecutionSet(IMRuleExecutionSet executionSet)
setExecutionSet
in interface IContext
IContext.setExecutionSet(com.massa.mrules.set.IMRuleExecutionSet)
public ICompilationContext getRootContext()
IContext
getRootContext
in interface ICompilationContext
getRootContext
in interface IContext