org.drools.spi
Interface KnowledgeHelper

All Superinterfaces:
org.drools.runtime.KnowledgeContext, org.drools.runtime.rule.RuleContext, Serializable
All Known Implementing Classes:
DefaultKnowledgeHelper, SequentialKnowledgeHelper

public interface KnowledgeHelper
extends org.drools.runtime.rule.RuleContext, Serializable

KnowledgeHelper implementation types are injected into consequenses instrumented at compile time and instances passed at runtime. It provides convenience methods for users to interact with the WorkingMemory.

Of particular interest is the update method as it allows an object to be modified without having to specify the facthandle, because they are not passed to the consequence at runtime. To achieve this the implementation will need to lookup the fact handle of the object form the WorkingMemory.


Method Summary
 void cancelRemainingPreviousLogicalDependencies()
           
<T,K> T
don(K core, Class<T> trait)
           
<T,K> T
don(K core, Class<T> trait, boolean logical)
           
<T,K> T
don(Thing<K> core, Class<T> trait)
           
<T,K> T
don(Thing<K> core, Class<T> trait, boolean logical)
           
 Object get(Declaration declaration)
           
 Activation getActivation()
           
 org.drools.runtime.Channel getChannel(String id)
           
 Map<String,org.drools.runtime.Channel> getChannels()
           
<T> T
getContext(Class<T> contextClass)
           
 Declaration getDeclaration(String identifier)
           
 org.drools.runtime.rule.WorkingMemoryEntryPoint getEntryPoint(String id)
           
 Map<String,org.drools.runtime.rule.WorkingMemoryEntryPoint> getEntryPoints()
           
 org.drools.runtime.ExitPoint getExitPoint(String id)
          Deprecated. Use getChannel(String) instead.
 Map<String,org.drools.runtime.ExitPoint> getExitPoints()
          Deprecated. Use getChannels() instead.
 FactHandle getFactHandle(FactHandle handle)
           
 FactHandle getFactHandle(Object object)
           
 IdentityHashMap<Object,FactHandle> getIdentityMap()
           
 Rule getRule()
           
 Tuple getTuple()
           
 WorkingMemory getWorkingMemory()
           
 void halt()
           
 void insert(Object object)
          Asserts an object, notice that it does not return the FactHandle
 void insert(Object object, boolean dynamic)
          Asserts an object specifying that it implement the onPropertyChange listener, notice that it does not return the FactHandle.
 void insertLogical(Object object)
           
 void insertLogical(Object object, boolean dynamic)
           
 void modify(Object newObject)
           
 void reset()
           
 void retract(FactHandle handle)
           
 void retract(Object handle)
           
 void setActivation(Activation agendaItem)
           
 void setFocus(String focus)
           
 void setIdentityMap(IdentityHashMap<Object,FactHandle> identityMap)
           
<T,K> Thing<K>
shed(Thing<K> thing, Class<T> trait)
           
<T,K> Thing<K>
shed(TraitableBean<K> core, Class<T> trait)
           
 void update(FactHandle newObject)
           
 void update(FactHandle handle, Object newObject)
           
 void update(Object newObject)
           
 
Methods inherited from interface org.drools.runtime.rule.RuleContext
blockActivation, cancelActivation, unblockAllActivations
 
Methods inherited from interface org.drools.runtime.KnowledgeContext
getKnowledgeRuntime
 

Method Detail

setActivation

void setActivation(Activation agendaItem)

reset

void reset()

insert

void insert(Object object)
Asserts an object, notice that it does not return the FactHandle

Parameters:
object - - the object to be asserted

insert

void insert(Object object,
            boolean dynamic)
Asserts an object specifying that it implement the onPropertyChange listener, notice that it does not return the FactHandle.

Parameters:
object - - the object to be asserted
dynamic - - specifies the object implements onPropertyChangeListener

insertLogical

void insertLogical(Object object)
Specified by:
insertLogical in interface org.drools.runtime.rule.RuleContext

insertLogical

void insertLogical(Object object,
                   boolean dynamic)

cancelRemainingPreviousLogicalDependencies

void cancelRemainingPreviousLogicalDependencies()

getFactHandle

FactHandle getFactHandle(Object object)

getFactHandle

FactHandle getFactHandle(FactHandle handle)

update

void update(FactHandle handle,
            Object newObject)

update

void update(FactHandle newObject)

update

void update(Object newObject)

modify

void modify(Object newObject)

retract

void retract(FactHandle handle)

retract

void retract(Object handle)

get

Object get(Declaration declaration)

getRule

Rule getRule()
Specified by:
getRule in interface org.drools.runtime.rule.RuleContext
Returns:
- The rule name

getTuple

Tuple getTuple()

getActivation

Activation getActivation()
Specified by:
getActivation in interface org.drools.runtime.rule.RuleContext

getWorkingMemory

WorkingMemory getWorkingMemory()

getEntryPoint

org.drools.runtime.rule.WorkingMemoryEntryPoint getEntryPoint(String id)

getEntryPoints

Map<String,org.drools.runtime.rule.WorkingMemoryEntryPoint> getEntryPoints()

getExitPoint

@Deprecated
org.drools.runtime.ExitPoint getExitPoint(String id)
Deprecated. Use getChannel(String) instead.


getExitPoints

@Deprecated
Map<String,org.drools.runtime.ExitPoint> getExitPoints()
Deprecated. Use getChannels() instead.


getChannel

org.drools.runtime.Channel getChannel(String id)

getChannels

Map<String,org.drools.runtime.Channel> getChannels()

setFocus

void setFocus(String focus)

getDeclaration

Declaration getDeclaration(String identifier)

halt

void halt()

getIdentityMap

IdentityHashMap<Object,FactHandle> getIdentityMap()

setIdentityMap

void setIdentityMap(IdentityHashMap<Object,FactHandle> identityMap)

getContext

<T> T getContext(Class<T> contextClass)

don

<T,K> T don(K core,
            Class<T> trait,
            boolean logical)

don

<T,K> T don(Thing<K> core,
            Class<T> trait,
            boolean logical)

don

<T,K> T don(K core,
            Class<T> trait)

don

<T,K> T don(Thing<K> core,
            Class<T> trait)

shed

<T,K> Thing<K> shed(Thing<K> thing,
                    Class<T> trait)

shed

<T,K> Thing<K> shed(TraitableBean<K> core,
                    Class<T> trait)


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