org.drools.reteoo
Class ReteooRuleBase

java.lang.Object
  extended by org.drools.common.AbstractRuleBase
      extended by org.drools.reteoo.ReteooRuleBase
All Implemented Interfaces:
Externalizable, Serializable, InternalRuleBase, RuleBase, RuleBaseEventManager

public class ReteooRuleBase
extends AbstractRuleBase

Implementation of RuleBase.

Version:
$Id: RuleBaseImpl.java,v 1.5 2005/08/14 22:44:12 mproctor Exp $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.drools.common.AbstractRuleBase
AbstractRuleBase.RuleBaseAction
 
Field Summary
 Set<EntryPointNode> addedEntryNodeCache
           
 Set<EntryPointNode> removedEntryNodeCache
           
 
Fields inherited from class org.drools.common.AbstractRuleBase
pkgs
 
Fields inherited from interface org.drools.RuleBase
RETEOO
 
Constructor Summary
ReteooRuleBase()
          Default constructor - for Externalizable.
ReteooRuleBase(RuleBaseConfiguration config)
           
ReteooRuleBase(String id)
          Construct.
ReteooRuleBase(String id, FactHandleFactory factHandleFactory)
           
ReteooRuleBase(String id, RuleBaseConfiguration config)
           
ReteooRuleBase(String id, RuleBaseConfiguration config, FactHandleFactory factHandleFactory)
          Construct.
 
Method Summary
protected  void addEntryPoint(String id)
          This method is called with the rulebase lock held.
 void addPackage(Package newPkg)
           
 void addPackages(Collection<Package> pkgs)
          Add a Package to the network.
 void addPackages(Package[] pkgs)
           
protected  void addRule(Rule rule)
          This method is called with the rulebase lock held.
 void assertObject(FactHandle handle, Object object, PropagationContext context, InternalWorkingMemory workingMemory)
          Assert a fact object.
 Set<EntryPointNode> getAddedEntryNodeCache()
           
 int getNodeCount()
           
 Set<EntryPointNode> getRemovedEntryNodeCache()
           
 Rete getRete()
          Retrieve the Rete-OO network for this RuleBase.
 ReteooBuilder getReteooBuilder()
           
 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.drools.runtime.Environment environment)
          Create a new WorkingMemory session for this RuleBase.
 StatelessSession newStatelessSession()
           
 void readExternal(ObjectInput stream)
          Handles the read serialization of the Package.
 void registerAddedEntryNodeCache(EntryPointNode node)
           
 void registeRremovedEntryNodeCache(EntryPointNode node)
           
protected  void removeRule(Rule rule)
          Handle rule removal.
 void retractObject(FactHandle handle, PropagationContext context, ReteooWorkingMemory workingMemory)
          Retract a fact object.
protected  void updateDependentTypes(Package newPkg, TypeDeclaration typeDeclaration)
           
 void writeExternal(ObjectOutput stream)
          Handles the write serialization of the Package.
 
Methods inherited from class org.drools.common.AbstractRuleBase
addEntryPoint, addEventListener, addProcess, addRule, addStatefulSession, createNewPartitionId, disposeStatefulSession, executeQueuedActions, getAdditionsSinceLock, getAgendaGroupRuleTotals, getClassFieldAccessorCache, getConfig, getConfiguration, getEntryPointIds, getFactHandleFactory, getFactType, getGlobals, getId, getPackage, getPackages, getPackagesMap, getPartitionIds, getProcess, getProcesses, getRemovalsSinceLock, getRootClassLoader, getRuleBaseEventListeners, getStatefulSessions, getTripleStore, getTypeDeclaration, getTypeDeclarations, getWorkingMemories, getWorkingMemoryCounter, isEvent, lock, newFactHandleFactory, newFactHandleFactory, newStatefulSession, nextWorkingMemoryCounter, readLock, readUnlock, removeEventListener, removeFunction, removeFunction, removePackage, removeProcess, removeQuery, removeRule, removeRule, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addedEntryNodeCache

public Set<EntryPointNode> addedEntryNodeCache

removedEntryNodeCache

public Set<EntryPointNode> removedEntryNodeCache
Constructor Detail

ReteooRuleBase

public ReteooRuleBase()
Default constructor - for Externalizable. This should never be used by a user, as it will result in an invalid state for the instance.


ReteooRuleBase

public ReteooRuleBase(String id)
Construct.

Parameters:
id - The rete network.

ReteooRuleBase

public ReteooRuleBase(String id,
                      FactHandleFactory factHandleFactory)
Parameters:
factHandleFactory -

ReteooRuleBase

public ReteooRuleBase(String id,
                      RuleBaseConfiguration config)

ReteooRuleBase

public ReteooRuleBase(RuleBaseConfiguration config)
Parameters:
config -

ReteooRuleBase

public ReteooRuleBase(String id,
                      RuleBaseConfiguration config,
                      FactHandleFactory factHandleFactory)
Construct.

Parameters:
id - The rete network.
Method Detail

writeExternal

public void writeExternal(ObjectOutput stream)
                   throws IOException
Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class AbstractRuleBase
Throws:
IOException

readExternal

public void readExternal(ObjectInput stream)
                  throws IOException,
                         ClassNotFoundException
Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules. A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class AbstractRuleBase
Throws:
IOException
ClassNotFoundException

registerAddedEntryNodeCache

public void registerAddedEntryNodeCache(EntryPointNode node)

getAddedEntryNodeCache

public Set<EntryPointNode> getAddedEntryNodeCache()

registeRremovedEntryNodeCache

public void registeRremovedEntryNodeCache(EntryPointNode node)

getRemovedEntryNodeCache

public Set<EntryPointNode> getRemovedEntryNodeCache()

getRete

public Rete getRete()
Retrieve the Rete-OO network for this RuleBase.

Returns:
The RETE-OO network.

getReteooBuilder

public ReteooBuilder getReteooBuilder()

assertObject

public void assertObject(FactHandle handle,
                         Object object,
                         PropagationContext context,
                         InternalWorkingMemory workingMemory)
                  throws FactException
Assert a fact object.

Parameters:
handle - The handle.
object - The fact.
workingMemory - The working-memory.
Throws:
FactException - If an error occurs while performing the assertion.

retractObject

public void retractObject(FactHandle handle,
                          PropagationContext context,
                          ReteooWorkingMemory workingMemory)
                   throws FactException
Retract a fact object.

Parameters:
handle - The handle.
workingMemory - The working-memory.
Throws:
FactException - If an error occurs while performing the retraction.

newStatefulSession

public StatefulSession newStatefulSession(boolean keepReference)

newStatefulSession

public StatefulSession newStatefulSession(InputStream stream)

newStatefulSession

public StatefulSession newStatefulSession(InputStream stream,
                                          boolean keepReference)

newStatefulSession

public StatefulSession newStatefulSession(InputStream stream,
                                          boolean keepReference,
                                          SessionConfiguration conf)

newStatefulSession

public StatefulSession newStatefulSession(SessionConfiguration sessionConfig,
                                          org.drools.runtime.Environment environment)
Description copied from interface: RuleBase
Create a new WorkingMemory session for this RuleBase.

Parameters:
sessionConfig - the session configuration object to use for the created session.
Returns:
A newly initialized WorkingMemory.
See Also:
WorkingMemory, org.drools.conflict.DefaultConflictResolver

newStatelessSession

public StatelessSession newStatelessSession()

addRule

protected void addRule(Rule rule)
                throws InvalidPatternException
Description copied from class: AbstractRuleBase
This method is called with the rulebase lock held.

Specified by:
addRule in class AbstractRuleBase
Throws:
InvalidPatternException

addEntryPoint

protected void addEntryPoint(String id)
                      throws InvalidPatternException
Description copied from class: AbstractRuleBase
This method is called with the rulebase lock held.

Specified by:
addEntryPoint in class AbstractRuleBase
Parameters:
id - the entry point ID
Throws:
InvalidPatternException

removeRule

protected void removeRule(Rule rule)
Description copied from class: AbstractRuleBase
Handle rule removal. This method is intended for sub-classes, and called after the before-rule-removed event is fired, and before the rule is physically removed from the package. This method is called with the rulebase lock held.

Specified by:
removeRule in class AbstractRuleBase

getNodeCount

public int getNodeCount()

addPackages

public void addPackages(Package[] pkgs)

addPackages

public void addPackages(Collection<Package> pkgs)
Description copied from class: AbstractRuleBase
Add a Package to the network. Iterates through the Package adding Each individual Rule to the network. Before update network each referenced WorkingMemory is locked.

Overrides:
addPackages in class AbstractRuleBase

addPackage

public void addPackage(Package newPkg)

updateDependentTypes

protected void updateDependentTypes(Package newPkg,
                                    TypeDeclaration typeDeclaration)
Specified by:
updateDependentTypes in class AbstractRuleBase


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