public class ReteooRuleBase extends Object implements InternalRuleBase, Externalizable
RuleBase
.Modifier and Type | Class and Description |
---|---|
static interface |
ReteooRuleBase.RuleBaseAction |
Modifier and Type | Field and Description |
---|---|
Set<EntryPointNode> |
addedEntryNodeCache |
protected static org.slf4j.Logger |
logger |
protected Map<String,Package> |
pkgs |
Set<EntryPointNode> |
removedEntryNodeCache |
Constructor and Description |
---|
ReteooRuleBase()
Default constructor - for Externalizable.
|
ReteooRuleBase(String id,
RuleBaseConfiguration config)
Construct.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEntryPoint(Package pkg,
String id) |
protected void |
addEntryPoint(String id) |
void |
addEventListener(RuleBaseEventListener listener)
Add an event listener.
|
void |
addPackage(Package newPkg) |
void |
addPackages(Collection<Package> newPkgs)
Add a
Package to the network. |
void |
addPackages(Package[] pkgs) |
void |
addProcess(org.kie.api.definition.process.Process process) |
void |
addRule(Package pkg,
Rule rule) |
protected void |
addRule(Rule rule) |
void |
addStatefulSession(StatefulSession statefulSession) |
void |
addWindowDeclaration(Package pkg,
WindowDeclaration window) |
protected void |
addWindowDeclaration(WindowDeclaration window) |
void |
assertObject(FactHandle handle,
Object object,
PropagationContext context,
InternalWorkingMemory workingMemory)
Assert a fact object.
|
RuleBasePartitionId |
createNewPartitionId()
Creates and allocates a new partition ID for this rulebase
|
void |
disposeStatefulSession(StatefulSession statefulSession) |
void |
executeQueuedActions() |
Set<EntryPointNode> |
getAddedEntryNodeCache() |
int |
getAdditionsSinceLock()
Returns the number of additive operations applied since the last lock() was obtained
|
ClassFieldAccessorCache |
getClassFieldAccessorCache() |
RuleBaseConfiguration |
getConfig() |
RuleBaseConfiguration |
getConfiguration() |
Set<String> |
getEntryPointIds() |
FactHandleFactory |
getFactHandleFactory() |
org.kie.api.definition.type.FactType |
getFactType(String name)
Returns a declared FactType.
|
Map<String,Class<?>> |
getGlobals() |
String |
getId() |
int |
getNodeCount() |
Package |
getPackage(String name) |
Package[] |
getPackages() |
Map<String,Package> |
getPackagesMap() |
List<RuleBasePartitionId> |
getPartitionIds()
Return the list of Partition IDs for this rulebase
|
org.kie.api.definition.process.Process |
getProcess(String id) |
org.kie.api.definition.process.Process[] |
getProcesses() |
int |
getRemovalsSinceLock()
Returns the number of removal operations applied since the last lock() was obtained
|
Set<EntryPointNode> |
getRemovedEntryNodeCache() |
Rete |
getRete()
Retrieve the Rete-OO network for this
RuleBase . |
ReteooBuilder |
getReteooBuilder() |
ClassLoader |
getRootClassLoader() |
List<RuleBaseEventListener> |
getRuleBaseEventListeners()
Returns all event listeners.
|
SegmentMemory |
getSegmentFromPrototype(InternalWorkingMemory wm,
LeftTupleSource tupleSource) |
StatefulSession[] |
getStatefulSessions()
Returns an array of all the referenced StatefulSessions
|
TraitRegistry |
getTraitRegistry() |
TripleStore |
getTripleStore() |
TypeDeclaration |
getTypeDeclaration(Class<?> clazz)
Returns the type declaration associated to the given class
|
Collection<TypeDeclaration> |
getTypeDeclarations()
Returns a collection with all TypeDeclarations in this rulebase
|
InternalWorkingMemory[] |
getWorkingMemories() |
int |
getWorkingMemoryCounter() |
void |
invalidateSegmentPrototype(LeftTupleSource tupleSource) |
boolean |
isEvent(Class<?> clazz)
Returns true if clazz represents an Event class.
|
void |
lock()
This locks the current RuleBase and all there referenced StatefulSessions.
|
FactHandleFactory |
newFactHandleFactory() |
FactHandleFactory |
newFactHandleFactory(int id,
long counter) |
StatefulSession |
newStatefulSession()
Create a new
WorkingMemory session for this
RuleBase . |
StatefulSession |
newStatefulSession(boolean keepReference) |
StatefulSession |
newStatefulSession(InputStream stream) |
StatefulSession |
newStatefulSession(InputStream stream,
boolean keepReference) |
StatefulSession |
newStatefulSession(InputStream stream,
boolean keepReference,
SessionConfiguration conf) |
StatefulSession |
newStatefulSession(SessionConfiguration sessionConfig,
org.kie.api.runtime.Environment environment)
Create a new
WorkingMemory session for this
RuleBase . |
StatelessSession |
newStatelessSession() |
int |
nextWorkingMemoryCounter() |
void |
readExternal(ObjectInput in)
Handles the read serialization of the Package.
|
void |
readLock()
Acquires a read lock on the rulebase
|
void |
readUnlock()
Releases a read lock on the rulebase
|
void |
registerAddedEntryNodeCache(EntryPointNode node) |
Class<?> |
registerAndLoadTypeDefinition(String className,
byte[] def) |
void |
registeRremovedEntryNodeCache(EntryPointNode node) |
void |
registerSegmentPrototype(LeftTupleSource tupleSource,
SegmentMemory smem) |
void |
removeEventListener(RuleBaseEventListener listener)
Remove an event listener.
|
protected void |
removeFunction(String functionName)
Handle function removal.
|
void |
removeFunction(String packageName,
String functionName)
Removes a specific function in a specific package.
|
boolean |
removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource) |
void |
removePackage(String packageName)
Remove the package and all it's rules, functions etc
|
void |
removeProcess(String id)
Removes a process by the process' id
|
void |
removeQuery(String packageName,
String ruleName)
Remove a specific Query in a Package
|
void |
removeRule(Package pkg,
Rule rule)
Notify listeners and sub-classes about imminent removal of a rule from a package.
|
protected void |
removeRule(Rule rule) |
void |
removeRule(String packageName,
String ruleName)
Remove a specific Rule in a Package
|
void |
retractObject(FactHandle handle,
PropagationContext context,
AbstractWorkingMemory workingMemory)
Retract a fact object.
|
protected void |
setupRete() |
void |
unlock()
Unlocks the RuleBase and all of the referenced StatefulSessions.
|
protected void |
updateDependentTypes(Package newPkg,
TypeDeclaration typeDeclaration) |
void |
writeExternal(ObjectOutput out)
Handles the write serialization of the Package.
|
protected static transient org.slf4j.Logger logger
public Set<EntryPointNode> addedEntryNodeCache
public Set<EntryPointNode> removedEntryNodeCache
public ReteooRuleBase()
public ReteooRuleBase(String id, RuleBaseConfiguration config)
id
- The rete network.public int nextWorkingMemoryCounter()
nextWorkingMemoryCounter
in interface InternalRuleBase
public int getWorkingMemoryCounter()
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public String getId()
getId
in interface InternalRuleBase
public RuleBaseConfiguration getConfig()
public StatefulSession newStatefulSession()
RuleBase
WorkingMemory
session for this
RuleBase
. By default the RuleBase retains a
weak reference to returned WorkingMemory.
The created WorkingMemory
uses the default conflict
resolution strategy.
newStatefulSession
in interface RuleBase
WorkingMemory
.
IMPORTANT: when using the stateful session REMEMBER TO CALL dispose()
when you are done with the session.RuleBase
public void disposeStatefulSession(StatefulSession statefulSession)
disposeStatefulSession
in interface InternalRuleBase
public FactHandleFactory getFactHandleFactory()
RuleBase
public FactHandleFactory newFactHandleFactory()
newFactHandleFactory
in interface InternalRuleBase
public FactHandleFactory newFactHandleFactory(int id, long counter)
newFactHandleFactory
in interface InternalRuleBase
public org.kie.api.definition.process.Process[] getProcesses()
getProcesses
in interface InternalRuleBase
public Package[] getPackages()
getPackages
in interface RuleBase
public Map<String,Package> getPackagesMap()
getPackagesMap
in interface InternalRuleBase
public Map<String,Class<?>> getGlobals()
getGlobals
in interface InternalRuleBase
public int getAdditionsSinceLock()
RuleBase
getAdditionsSinceLock
in interface RuleBase
public int getRemovalsSinceLock()
RuleBase
getRemovalsSinceLock
in interface RuleBase
public void lock()
RuleBase
public void unlock()
RuleBase
public void readLock()
InternalRuleBase
readLock
in interface InternalRuleBase
public void readUnlock()
InternalRuleBase
readUnlock
in interface InternalRuleBase
public void addPackages(Collection<Package> newPkgs)
Package
to the network. Iterates through the
Package
adding Each individual Rule
to the
network. Before update network each referenced WorkingMemory
is locked.newPkgs
- The package to add.public Class<?> registerAndLoadTypeDefinition(String className, byte[] def) throws ClassNotFoundException
ClassNotFoundException
protected void updateDependentTypes(Package newPkg, TypeDeclaration typeDeclaration)
protected void setupRete()
public void registerAddedEntryNodeCache(EntryPointNode node)
registerAddedEntryNodeCache
in interface InternalRuleBase
public Set<EntryPointNode> getAddedEntryNodeCache()
getAddedEntryNodeCache
in interface InternalRuleBase
public void registeRremovedEntryNodeCache(EntryPointNode node)
registeRremovedEntryNodeCache
in interface InternalRuleBase
public Set<EntryPointNode> getRemovedEntryNodeCache()
getRemovedEntryNodeCache
in interface InternalRuleBase
public Rete getRete()
RuleBase
.getRete
in interface InternalRuleBase
public ReteooBuilder getReteooBuilder()
getReteooBuilder
in interface InternalRuleBase
public void assertObject(FactHandle handle, Object object, PropagationContext context, InternalWorkingMemory workingMemory) throws FactException
assertObject
in interface InternalRuleBase
handle
- The handle.object
- The fact.workingMemory
- The working-memory.FactException
- If an error occurs while performing the assertion.public void retractObject(FactHandle handle, PropagationContext context, AbstractWorkingMemory workingMemory) throws FactException
retractObject
in interface InternalRuleBase
handle
- The handle.workingMemory
- The working-memory.FactException
- If an error occurs while performing the retraction.public StatefulSession newStatefulSession(boolean keepReference)
newStatefulSession
in interface RuleBase
public StatefulSession newStatefulSession(InputStream stream)
newStatefulSession
in interface RuleBase
public StatefulSession newStatefulSession(InputStream stream, boolean keepReference)
newStatefulSession
in interface RuleBase
public StatefulSession newStatefulSession(InputStream stream, boolean keepReference, SessionConfiguration conf)
newStatefulSession
in interface RuleBase
public StatefulSession newStatefulSession(SessionConfiguration sessionConfig, org.kie.api.runtime.Environment environment)
RuleBase
WorkingMemory
session for this
RuleBase
.newStatefulSession
in interface RuleBase
sessionConfig
- the session configuration object to use for the
created session.WorkingMemory
.WorkingMemory
,
org.kie.conflict.DefaultConflictResolver
public StatelessSession newStatelessSession()
newStatelessSession
in interface RuleBase
public int getNodeCount()
getNodeCount
in interface InternalRuleBase
public void addPackages(Package[] pkgs)
addPackages
in interface RuleBase
public void addPackage(Package newPkg)
addPackage
in interface RuleBase
public void registerSegmentPrototype(LeftTupleSource tupleSource, SegmentMemory smem)
public void invalidateSegmentPrototype(LeftTupleSource tupleSource)
public SegmentMemory getSegmentFromPrototype(InternalWorkingMemory wm, LeftTupleSource tupleSource)
public TypeDeclaration getTypeDeclaration(Class<?> clazz)
InternalRuleBase
getTypeDeclaration
in interface InternalRuleBase
public Collection<TypeDeclaration> getTypeDeclarations()
InternalRuleBase
getTypeDeclarations
in interface InternalRuleBase
public void addRule(Package pkg, Rule rule) throws InvalidPatternException
InvalidPatternException
protected void addEntryPoint(Package pkg, String id) throws InvalidPatternException
InvalidPatternException
protected void addRule(Rule rule) throws InvalidPatternException
InvalidPatternException
protected void addEntryPoint(String id) throws InvalidPatternException
InvalidPatternException
public void addWindowDeclaration(Package pkg, WindowDeclaration window) throws InvalidPatternException
InvalidPatternException
protected void addWindowDeclaration(WindowDeclaration window) throws InvalidPatternException
InvalidPatternException
public void removePackage(String packageName)
RuleBase
removePackage
in interface RuleBase
public void removeQuery(String packageName, String ruleName)
RuleBase
removeQuery
in interface RuleBase
public void removeRule(String packageName, String ruleName)
RuleBase
removeRule
in interface RuleBase
public void removeRule(Package pkg, Rule rule)
pkg
- rule
- protected void removeRule(Rule rule)
public void removeFunction(String packageName, String functionName)
RuleBase
removeFunction
in interface RuleBase
protected void removeFunction(String functionName)
before-rule-removed
event is fired, and before the function is physically removed from the package.
This method is called with the rulebase lock held.functionName
- public void addProcess(org.kie.api.definition.process.Process process)
public void removeProcess(String id)
RuleBase
removeProcess
in interface RuleBase
public org.kie.api.definition.process.Process getProcess(String id)
getProcess
in interface InternalRuleBase
public void addStatefulSession(StatefulSession statefulSession)
public Package getPackage(String name)
getPackage
in interface InternalRuleBase
getPackage
in interface RuleBase
public StatefulSession[] getStatefulSessions()
RuleBase
getStatefulSessions
in interface RuleBase
public InternalWorkingMemory[] getWorkingMemories()
getWorkingMemories
in interface InternalRuleBase
public RuleBaseConfiguration getConfiguration()
getConfiguration
in interface InternalRuleBase
public ClassLoader getRootClassLoader()
getRootClassLoader
in interface InternalRuleBase
public void executeQueuedActions()
executeQueuedActions
in interface InternalRuleBase
public RuleBasePartitionId createNewPartitionId()
InternalRuleBase
createNewPartitionId
in interface InternalRuleBase
public List<RuleBasePartitionId> getPartitionIds()
InternalRuleBase
getPartitionIds
in interface InternalRuleBase
public void addEventListener(RuleBaseEventListener listener)
RuleBaseEventManager
addEventListener
in interface RuleBaseEventManager
listener
- The listener to add.public void removeEventListener(RuleBaseEventListener listener)
RuleBaseEventManager
removeEventListener
in interface RuleBaseEventManager
listener
- The listener to remove.public List<RuleBaseEventListener> getRuleBaseEventListeners()
RuleBaseEventManager
getRuleBaseEventListeners
in interface RuleBaseEventManager
public boolean isEvent(Class<?> clazz)
InternalRuleBase
isEvent
in interface InternalRuleBase
public org.kie.api.definition.type.FactType getFactType(String name)
RuleBase
getFactType
in interface RuleBase
name
- - the name of the declared type (a type defined in the rules).
This would typically be packagename + . + type name.
Eg, if there is a delcared type of name "Driver", and the package name is "com.company".
Then the string you pass in would be "com.company.Driver".public ClassFieldAccessorCache getClassFieldAccessorCache()
public Set<String> getEntryPointIds()
getEntryPointIds
in interface RuleBase
public TripleStore getTripleStore()
public TraitRegistry getTraitRegistry()
public boolean removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource)
Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.