Package org.kie.api.runtime.manager
Interface RuntimeManager
-
public interface RuntimeManager
RuntimeManager managesRuntimeEngine
s that are essentially build withKieSession
andTaskService
to deliver executable environments for processes and user tasks.
MoreoverRuntimeManager
ensures that all components are configured and bootstrapped as soon as manager is instantiated to ensure its fully featured functionality right from the start. That includes:- timer service
- task service
- finds and initializes timer start events based processes
RuntimeManager
s are identified by unique identifiers and thus there cannot be two RuntimeManagers with the same id active at the same time in the same system.
RuntimeManager implements runtime strategy that provides certain management capabilities to reduce manual work needed to control ksession behavior. Which mainly covers when to create, dispose and when to use which ksession. Currently there are three predefined strategies:- Singleton - there is only one, always active ksession for the manager, access to it is thread safe that is achieved by synchronization which applies to both ksession and task service
- PerRequest - new ksession and task service instances will be returned for every invocation of the getRuntimeEngine(Context) method. Important to know is same instance of RuntimeEngine will be returned through out transaction to avoid issues with persistence context.
- PerProcessInstance - most advanced strategy that keeps track of which ksession was used to work with given process instance. It lives as long as process instance is alive and is destroyed when process instance is completed/aborted.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
ClosesRuntimeManager
and releases it's resources.void
disposeRuntimeEngine(RuntimeEngine runtime)
DisposesRuntimeEngine
and notifies all listeners about that fact.java.lang.String
getIdentifier()
RuntimeEngine
getRuntimeEngine(Context<?> context)
ReturnsRuntimeEngine
instance that is fully initialized: KiseSession is created or loaded depending on the strategy TaskService is initialized and attached to ksession (via listener) WorkItemHandlers are initialized and registered on ksession EventListeners (process, agenda, working memory) are initialized and added to ksessionvoid
signalEvent(java.lang.String type, java.lang.Object event)
Allows to signal event on runtime manager level which in turn allows to broadcast given event to all listening components managed by this RuntimeManager
-
-
-
Method Detail
-
getRuntimeEngine
RuntimeEngine getRuntimeEngine(Context<?> context)
ReturnsRuntimeEngine
instance that is fully initialized:- KiseSession is created or loaded depending on the strategy
- TaskService is initialized and attached to ksession (via listener)
- WorkItemHandlers are initialized and registered on ksession
- EventListeners (process, agenda, working memory) are initialized and added to ksession
- Parameters:
context
- the concrete implementation of the context that is supported by givenRuntimeManager
- Returns:
- instance of the
RuntimeEngine
-
getIdentifier
java.lang.String getIdentifier()
- Returns:
- unique identifier of this
RuntimeManager
-
disposeRuntimeEngine
void disposeRuntimeEngine(RuntimeEngine runtime)
DisposesRuntimeEngine
and notifies all listeners about that fact. This method should always be used to disposeRuntimeEngine
that is not needed anymore.
ksession.dispose() shall never be used with RuntimeManager as it will break the internal mechanisms of the manager responsible for clear and efficient disposal.
Dispose is not needed ifRuntimeEngine
was obtained within active JTA transaction, this means that when getRuntimeEngine method was invoked during active JTA transaction then dispose of the runtime engine will happen automatically on transaction completion.- Parameters:
runtime
-
-
close
void close()
ClosesRuntimeManager
and releases it's resources. Shall always be called when runtime manager is not needed any more. Otherwise it will still be active and operational.
-
signalEvent
void signalEvent(java.lang.String type, java.lang.Object event)
Allows to signal event on runtime manager level which in turn allows to broadcast given event to all listening components managed by this RuntimeManager- Parameters:
type
- type of the signalevent
- actual event data
-
-