Knowledge API Legacy5 Adapter 6.0.0.Beta3

org.drools.impl.adapters
Class KnowledgeRuntimeAdapter

java.lang.Object
  extended by org.drools.impl.adapters.KnowledgeRuntimeAdapter
All Implemented Interfaces:
KnowledgeRuntimeEventManager, ProcessEventManager, WorkingMemoryEventManager, KnowledgeRuntime, ProcessRuntime, WorkingMemory, WorkingMemoryEntryPoint
Direct Known Subclasses:
StatefulKnowledgeSessionAdapter

public class KnowledgeRuntimeAdapter
extends Object
implements KnowledgeRuntime


Field Summary
protected  org.kie.internal.runtime.KnowledgeRuntime delegate
           
 
Constructor Summary
KnowledgeRuntimeAdapter(org.kie.internal.runtime.KnowledgeRuntime delegate)
           
 
Method Summary
 void abortProcessInstance(long processInstanceId)
          Aborts the process instance with the given id.
 void addEventListener(AgendaEventListener listener)
          Add an event listener.
 void addEventListener(ProcessEventListener listener)
          Add a process event listener.
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 ProcessInstance createProcessInstance(String processId, Map<String,Object> parameters)
          Creates a new process instance (but does not yet start it).
 Agenda getAgenda()
          Returns a reference to this session's Agenda.
 Collection<AgendaEventListener> getAgendaEventListeners()
          Returns all event listeners.
 Calendars getCalendars()
           
 Map<String,Channel> getChannels()
           
 String getEntryPointId()
          Returns the String Id of this entry point
 Environment getEnvironment()
           
 long getFactCount()
          Returns the total number of facts currently in this entry point
 FactHandle getFactHandle(Object object)
          Returns the fact handle associated with the given object.
<T extends FactHandle>
Collection<T>
getFactHandles()
          Returns all FactHandles from the current session.
<T extends FactHandle>
Collection<T>
getFactHandles(ObjectFilter filter)
          Returns all FactHandles from the current session for which the facts are accepted by the given filter.
 Object getGlobal(String identifier)
           
 Globals getGlobals()
           
 KnowledgeBase getKnowledgeBase()
          Returns the KnowledgeBase reference from which this stateful session was created.
 Object getObject(FactHandle factHandle)
          Returns the object associated with the given FactHandle.
 Collection<Object> getObjects()
           Returns all facts from the current session as a Collection.
 Collection<Object> getObjects(ObjectFilter filter)
          Returns all facts from the current session that are accepted by the given ObjectFilter.
 Collection<ProcessEventListener> getProcessEventListeners()
          Returns all event listeners.
 ProcessInstance getProcessInstance(long processInstanceId)
          Returns the process instance with the given id.
 Collection<ProcessInstance> getProcessInstances()
          Returns a collection of currently active process instances.
 QueryResults getQueryResults(String query, Object... arguments)
          Retrieve the QueryResults of the specified query and arguments
<T extends SessionClock>
T
getSessionClock()
          Returns the session clock instance assigned to this session
 KnowledgeSessionConfiguration getSessionConfiguration()
           
 WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name)
          Returns the WorkingMemoryEntryPoint instance associated with the given name.
 Collection<? extends WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()
          Returns a collection of all available working memory entry points for this session.
 Collection<WorkingMemoryEventListener> getWorkingMemoryEventListeners()
          Returns all event listeners.
 WorkItemManager getWorkItemManager()
          Returns the WorkItemManager related to this session.
 void halt()
          Request the engine to stop firing rules.
 FactHandle insert(Object object)
          Inserts a new fact into this entry point
 LiveQuery openLiveQuery(String query, Object[] arguments, ViewChangedEventListener listener)
           
 void registerChannel(String name, Channel channel)
           
 void registerExitPoint(String name, ExitPoint exitPoint)
           
 void removeEventListener(AgendaEventListener listener)
          Remove an event listener.
 void removeEventListener(ProcessEventListener listener)
          Remove a process event listener.
 void removeEventListener(WorkingMemoryEventListener listener)
          Remove an event listener.
 void retract(FactHandle handle)
          Retracts the fact for which the given FactHandle was assigned.
 void setGlobal(String identifier, Object value)
          Sets a global value on the internal collection
 void signalEvent(String type, Object event)
          Signals the engine that an event has occurred.
 void signalEvent(String type, Object event, long processInstanceId)
          Signals the process instance that an event has occurred.
 ProcessInstance startProcess(String processId)
          Start a new process instance.
 ProcessInstance startProcess(String processId, Map<String,Object> parameters)
          Start a new process instance.
 ProcessInstance startProcessInstance(long processInstanceId)
          Starts the given process instance (which was created by using createProcesInstance but not yet started).
 void unregisterChannel(String name)
           
 void unregisterExitPoint(String name)
           
 void update(FactHandle handle, Object object)
          Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected final org.kie.internal.runtime.KnowledgeRuntime delegate
Constructor Detail

KnowledgeRuntimeAdapter

public KnowledgeRuntimeAdapter(org.kie.internal.runtime.KnowledgeRuntime delegate)
Method Detail

getSessionClock

public <T extends SessionClock> T getSessionClock()
Description copied from interface: KnowledgeRuntime
Returns the session clock instance assigned to this session

Specified by:
getSessionClock in interface KnowledgeRuntime
Returns:

setGlobal

public void setGlobal(String identifier,
                      Object value)
Description copied from interface: KnowledgeRuntime
Sets a global value on the internal collection

Specified by:
setGlobal in interface KnowledgeRuntime
Parameters:
identifier - the global identifier
value - the value assigned to the global identifier

getGlobal

public Object getGlobal(String identifier)
Specified by:
getGlobal in interface KnowledgeRuntime

getGlobals

public Globals getGlobals()
Specified by:
getGlobals in interface KnowledgeRuntime

getCalendars

public Calendars getCalendars()
Specified by:
getCalendars in interface KnowledgeRuntime

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface KnowledgeRuntime

getKnowledgeBase

public KnowledgeBase getKnowledgeBase()
Description copied from interface: KnowledgeRuntime
Returns the KnowledgeBase reference from which this stateful session was created.

Specified by:
getKnowledgeBase in interface KnowledgeRuntime
Returns:

registerExitPoint

public void registerExitPoint(String name,
                              ExitPoint exitPoint)
Specified by:
registerExitPoint in interface KnowledgeRuntime

unregisterExitPoint

public void unregisterExitPoint(String name)
Specified by:
unregisterExitPoint in interface KnowledgeRuntime

registerChannel

public void registerChannel(String name,
                            Channel channel)
Specified by:
registerChannel in interface KnowledgeRuntime

unregisterChannel

public void unregisterChannel(String name)
Specified by:
unregisterChannel in interface KnowledgeRuntime

getChannels

public Map<String,Channel> getChannels()
Specified by:
getChannels in interface KnowledgeRuntime

getSessionConfiguration

public KnowledgeSessionConfiguration getSessionConfiguration()
Specified by:
getSessionConfiguration in interface KnowledgeRuntime

addEventListener

public void addEventListener(ProcessEventListener listener)
Description copied from interface: ProcessEventManager
Add a process event listener.

Specified by:
addEventListener in interface ProcessEventManager
Parameters:
listener - the listener to add.

removeEventListener

public void removeEventListener(ProcessEventListener listener)
Description copied from interface: ProcessEventManager
Remove a process event listener.

Specified by:
removeEventListener in interface ProcessEventManager
Parameters:
listener - the listener to remove

getProcessEventListeners

public Collection<ProcessEventListener> getProcessEventListeners()
Description copied from interface: ProcessEventManager
Returns all event listeners.

Specified by:
getProcessEventListeners in interface ProcessEventManager
Returns:
listeners the listeners

startProcess

public ProcessInstance startProcess(String processId)
Description copied from interface: ProcessRuntime
Start a new process instance. The process (definition) that should be used is referenced by the given process id.

Specified by:
startProcess in interface ProcessRuntime
Parameters:
processId - The id of the process that should be started
Returns:
the ProcessInstance that represents the instance of the process that was started

startProcess

public ProcessInstance startProcess(String processId,
                                    Map<String,Object> parameters)
Description copied from interface: ProcessRuntime
Start a new process instance. The process (definition) that should be used is referenced by the given process id. Parameters can be passed to the process instance (as name-value pairs), and these will be set as variables of the process instance.

Specified by:
startProcess in interface ProcessRuntime
Parameters:
processId - the id of the process that should be started
parameters - the process variables that should be set when starting the process instance
Returns:
the ProcessInstance that represents the instance of the process that was started

createProcessInstance

public ProcessInstance createProcessInstance(String processId,
                                             Map<String,Object> parameters)
Description copied from interface: ProcessRuntime
Creates a new process instance (but does not yet start it). The process (definition) that should be used is referenced by the given process id. Parameters can be passed to the process instance (as name-value pairs), and these will be set as variables of the process instance. You should only use this method if you need a reference to the process instance before actually starting it. Otherwise, use startProcess.

Specified by:
createProcessInstance in interface ProcessRuntime
Parameters:
processId - the id of the process that should be started
parameters - the process variables that should be set when creating the process instance
Returns:
the ProcessInstance that represents the instance of the process that was created (but not yet started)

startProcessInstance

public ProcessInstance startProcessInstance(long processInstanceId)
Description copied from interface: ProcessRuntime
Starts the given process instance (which was created by using createProcesInstance but not yet started). This method can only be called once for each process instance. You should only use this method if you need a reference to the process instance before actually starting it. Otherwise, use startProcess.

Specified by:
startProcessInstance in interface ProcessRuntime
Parameters:
processInstanceId - the id of the process instance that needs to be started
Returns:
the ProcessInstance that represents the instance of the process that was started

signalEvent

public void signalEvent(String type,
                        Object event)
Description copied from interface: ProcessRuntime
Signals the engine that an event has occurred. The type parameter defines which type of event and the event parameter can contain additional information related to the event. All process instances that are listening to this type of (external) event will be notified. For performance reasons, this type of event signaling should only be used if one process instance should be able to notify other process instances. For internal event within one process instance, use the signalEvent method that also include the processInstanceId of the process instance in question.

Specified by:
signalEvent in interface ProcessRuntime
Parameters:
type - the type of event
event - the data associated with this event

signalEvent

public void signalEvent(String type,
                        Object event,
                        long processInstanceId)
Description copied from interface: ProcessRuntime
Signals the process instance that an event has occurred. The type parameter defines which type of event and the event parameter can contain additional information related to the event. All node instances inside the given process instance that are listening to this type of (internal) event will be notified. Note that the event will only be processed inside the given process instance. All other process instances waiting for this type of event will not be notified.

Specified by:
signalEvent in interface ProcessRuntime
Parameters:
type - the type of event
event - the data associated with this event
processInstanceId - the id of the process instance that should be signaled

getProcessInstances

public Collection<ProcessInstance> getProcessInstances()
Description copied from interface: ProcessRuntime
Returns a collection of currently active process instances. Note that only process instances that are currently loaded and active inside the engine will be returned. When using persistence, it is likely not all running process instances will be loaded as their state will be stored persistently. It is recommended not to use this method to collect information about the state of your process instances but to use a history log for that purpose.

Specified by:
getProcessInstances in interface ProcessRuntime
Returns:
a collection of process instances currently active in the session

getProcessInstance

public ProcessInstance getProcessInstance(long processInstanceId)
Description copied from interface: ProcessRuntime
Returns the process instance with the given id. Note that only active process instances will be returned. If a process instance has been completed already, this method will return null.

Specified by:
getProcessInstance in interface ProcessRuntime
Returns:
the process instance with the given id or null if it cannot be found

abortProcessInstance

public void abortProcessInstance(long processInstanceId)
Description copied from interface: ProcessRuntime
Aborts the process instance with the given id. If the process instance has been completed (or aborted), or the process instance cannot be found, this method will throw an IllegalArgumentException.

Specified by:
abortProcessInstance in interface ProcessRuntime

getWorkItemManager

public WorkItemManager getWorkItemManager()
Description copied from interface: ProcessRuntime
Returns the WorkItemManager related to this session. This can be used to register new WorkItemHandlers or to complete (or abort) WorkItems.

Specified by:
getWorkItemManager in interface ProcessRuntime
Returns:
the WorkItemManager related to this session

halt

public void halt()
Description copied from interface: WorkingMemory

Request the engine to stop firing rules. If the engine is currently firing a rule, it will finish executing this rule's consequence before stopping.

This method will not remove active activations from the Agenda. In case the application later wants to continue firing rules from the point where it stopped, it should just call org.drools.core.runtime.StatefulKnowledgeSession.fireAllRules() or org.drools.core.runtime.StatefulKnowledgeSession.fireUntilHalt() again.

Specified by:
halt in interface WorkingMemory

getAgenda

public Agenda getAgenda()
Description copied from interface: WorkingMemory
Returns a reference to this session's Agenda.

Specified by:
getAgenda in interface WorkingMemory
Returns:

getWorkingMemoryEntryPoint

public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name)
Description copied from interface: WorkingMemory
Returns the WorkingMemoryEntryPoint instance associated with the given name.

Specified by:
getWorkingMemoryEntryPoint in interface WorkingMemory
Returns:

getWorkingMemoryEntryPoints

public Collection<? extends WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()
Description copied from interface: WorkingMemory
Returns a collection of all available working memory entry points for this session.

Specified by:
getWorkingMemoryEntryPoints in interface WorkingMemory
Returns:
the collection of all available entry points for this session

getQueryResults

public QueryResults getQueryResults(String query,
                                    Object... arguments)
Description copied from interface: WorkingMemory
Retrieve the QueryResults of the specified query and arguments

Specified by:
getQueryResults in interface WorkingMemory
Parameters:
query - The name of the query.
arguments - The arguments used for the query
Returns:
The QueryResults of the specified query. If the query does not exist or no results match the query it is empty.

openLiveQuery

public LiveQuery openLiveQuery(String query,
                               Object[] arguments,
                               ViewChangedEventListener listener)
Specified by:
openLiveQuery in interface WorkingMemory

getEntryPointId

public String getEntryPointId()
Description copied from interface: WorkingMemoryEntryPoint
Returns the String Id of this entry point

Specified by:
getEntryPointId in interface WorkingMemoryEntryPoint
Returns:

insert

public FactHandle insert(Object object)
Description copied from interface: WorkingMemoryEntryPoint
Inserts a new fact into this entry point

Specified by:
insert in interface WorkingMemoryEntryPoint
Parameters:
object - the fact to be inserted
Returns:
the fact handle created for the given fact

retract

public void retract(FactHandle handle)
Description copied from interface: WorkingMemoryEntryPoint
Retracts the fact for which the given FactHandle was assigned.

Specified by:
retract in interface WorkingMemoryEntryPoint
Parameters:
handle - the handle whose fact is to be retracted.

update

public void update(FactHandle handle,
                   Object object)
Description copied from interface: WorkingMemoryEntryPoint
Updates the fact for which the given FactHandle was assigned with the new fact set as the second parameter in this method.

Specified by:
update in interface WorkingMemoryEntryPoint
Parameters:
handle - the FactHandle for the fact to be updated.
object - the new value for the fact being updated.

getFactHandle

public FactHandle getFactHandle(Object object)
Description copied from interface: WorkingMemoryEntryPoint
Returns the fact handle associated with the given object. It is important to note that this method behaves in accordance with the configured assert behaviour for this knowledge base (either IDENTITY or EQUALITY).

Specified by:
getFactHandle in interface WorkingMemoryEntryPoint
Parameters:
object - the fact for which the fact handle will be returned.
Returns:
the fact handle for the given object, or null in case no fact handle was found for the given object.
See Also:
KnowledgeBaseConfiguration

getObject

public Object getObject(FactHandle factHandle)
Description copied from interface: WorkingMemoryEntryPoint
Returns the object associated with the given FactHandle.

Specified by:
getObject in interface WorkingMemoryEntryPoint
Returns:

getObjects

public Collection<Object> getObjects()
Description copied from interface: WorkingMemoryEntryPoint

Returns all facts from the current session as a Collection.

This class is not a general-purpose Collection implementation! While this class implements the Collection interface, it intentionally violates Collection general contract, which mandates the use of the equals method when comparing objects.

Instead the approach used when comparing objects with the contains(Object) method is dependent on the WorkingMemory configuration, where it can be configured for Identity or for Equality.

Specified by:
getObjects in interface WorkingMemoryEntryPoint
Returns:

getObjects

public Collection<Object> getObjects(ObjectFilter filter)
Description copied from interface: WorkingMemoryEntryPoint
Returns all facts from the current session that are accepted by the given ObjectFilter.

Specified by:
getObjects in interface WorkingMemoryEntryPoint
Parameters:
filter - the filter to be applied to the returned collection of facts.
Returns:

getFactHandles

public <T extends FactHandle> Collection<T> getFactHandles()
Description copied from interface: WorkingMemoryEntryPoint
Returns all FactHandles from the current session.

Specified by:
getFactHandles in interface WorkingMemoryEntryPoint
Returns:

getFactHandles

public <T extends FactHandle> Collection<T> getFactHandles(ObjectFilter filter)
Description copied from interface: WorkingMemoryEntryPoint
Returns all FactHandles from the current session for which the facts are accepted by the given filter.

Specified by:
getFactHandles in interface WorkingMemoryEntryPoint
Parameters:
filter - the filter to be applied to the returned collection of FactHandles.
Returns:

getFactCount

public long getFactCount()
Description copied from interface: WorkingMemoryEntryPoint
Returns the total number of facts currently in this entry point

Specified by:
getFactCount in interface WorkingMemoryEntryPoint
Returns:

addEventListener

public void addEventListener(WorkingMemoryEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Add an event listener.

Specified by:
addEventListener in interface WorkingMemoryEventManager
Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(WorkingMemoryEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Remove an event listener.

Specified by:
removeEventListener in interface WorkingMemoryEventManager
Parameters:
listener - The listener to remove.

getWorkingMemoryEventListeners

public Collection<WorkingMemoryEventListener> getWorkingMemoryEventListeners()
Description copied from interface: WorkingMemoryEventManager
Returns all event listeners.

Specified by:
getWorkingMemoryEventListeners in interface WorkingMemoryEventManager
Returns:
listeners The listeners.

addEventListener

public void addEventListener(AgendaEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Add an event listener.

Specified by:
addEventListener in interface WorkingMemoryEventManager
Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(AgendaEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Remove an event listener.

Specified by:
removeEventListener in interface WorkingMemoryEventManager
Parameters:
listener - The listener to remove.

getAgendaEventListeners

public Collection<AgendaEventListener> getAgendaEventListeners()
Description copied from interface: WorkingMemoryEventManager
Returns all event listeners.

Specified by:
getAgendaEventListeners in interface WorkingMemoryEventManager
Returns:
listeners The listeners.

Knowledge API Legacy5 Adapter 6.0.0.Beta3

Copyright © 2001-2013 JBoss by Red Hat. All Rights Reserved.