站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 3.0.6 API 英文版文档

AbstractRuleBase - JBoss RULES 3.0.6 API 英文版文档


org.drools.common
Class AbstractRuleBase

java.lang.Object
  extended by org.drools.common.AbstractRuleBase
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, InternalRuleBase, RuleBase
Direct Known Subclasses:
LeapsRuleBase, ReteooRuleBase

public abstract class AbstractRuleBase
extends java.lang.Object
implements InternalRuleBase, java.io.Externalizable

Implementation of RuleBase.

See Also:
Serialized Form

Field Summary
protected  RuleBaseConfiguration config
           
protected  FactHandleFactory factHandleFactory
          The fact handle factory.
protected  java.util.Map globals
           
protected  CompositePackageClassLoader packageClassLoader
           
protected  java.util.Map pkgs
           
protected static java.lang.Object PRESENT
          Special value when adding to the underlying map.
protected  java.util.Map workingMemories
          WeakHashMap to keep references of WorkingMemories but allow them to be garbage collected
 
Fields inherited from interface org.drools.RuleBase
LEAPS, RETEOO
 
Constructor Summary
AbstractRuleBase(RuleBaseConfiguration config, FactHandleFactory factHandleFactory)
          Construct.
 
Method Summary
 void addPackage(Package newPkg)
          Add a Package to the network.
protected  void addRule(Rule rule)
           
protected  void addWorkingMemory(WorkingMemory workingMemory, boolean keepReference)
           
 void disposeWorkingMemory(WorkingMemory workingMemory)
           
 void doReadExternal(java.io.ObjectInput stream, java.lang.Object[] objects)
          Handles the read serialization of the Package.
 void doWriteExternal(java.io.ObjectOutput stream, java.lang.Object[] objects)
          Handles the write serialization of the Package.
 RuleBaseConfiguration getConfiguration()
           
 FactHandleFactory getFactHandleFactory()
           
 java.util.Map getGlobals()
           
 Package[] getPackages()
           
 java.util.Set getWorkingMemories()
           
 FactHandleFactory newFactHandleFactory()
           
 WorkingMemory newWorkingMemory()
          Create a new WorkingMemory session for this RuleBase.
abstract  WorkingMemory newWorkingMemory(boolean keepReference)
          Create a new WorkingMemory session for this RuleBase.
 WorkingMemory newWorkingMemory(java.io.InputStream stream)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 WorkingMemory newWorkingMemory(java.io.InputStream stream, boolean keepReference)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 void removePackage(java.lang.String packageName)
           
protected abstract  void removeRule(Rule rule)
           
 void removeRule(java.lang.String packageName, java.lang.String ruleName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.drools.common.InternalRuleBase
assertObject, modifyObject, retractObject
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

config

protected RuleBaseConfiguration config

pkgs

protected java.util.Map pkgs

packageClassLoader

protected transient CompositePackageClassLoader packageClassLoader

factHandleFactory

protected FactHandleFactory factHandleFactory
The fact handle factory.


globals

protected java.util.Map globals

workingMemories

protected transient java.util.Map workingMemories
WeakHashMap to keep references of WorkingMemories but allow them to be garbage collected


PRESENT

protected static final java.lang.Object PRESENT
Special value when adding to the underlying map.

Constructor Detail

AbstractRuleBase

public AbstractRuleBase(RuleBaseConfiguration config,
                        FactHandleFactory factHandleFactory)
Construct.

Parameters:
rete - The rete network.
Method Detail

doWriteExternal

public void doWriteExternal(java.io.ObjectOutput stream,
                            java.lang.Object[] objects)
                     throws java.io.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.

Throws:
java.io.IOException

doReadExternal

public void doReadExternal(java.io.ObjectInput stream,
                           java.lang.Object[] objects)
                    throws java.io.IOException,
                           java.lang.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.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

newWorkingMemory

public WorkingMemory newWorkingMemory()
Description copied from interface: RuleBase
Create a new 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.

Specified by:
newWorkingMemory in interface RuleBase
Returns:
A newly initialized WorkingMemory.
See Also:
RuleBase

newWorkingMemory

public abstract WorkingMemory newWorkingMemory(boolean keepReference)
Description copied from interface: RuleBase
Create a new WorkingMemory session for this RuleBase. Optionally the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Specified by:
newWorkingMemory in interface RuleBase
Returns:
A newly initialized WorkingMemory.
See Also:
RuleBase

disposeWorkingMemory

public void disposeWorkingMemory(WorkingMemory workingMemory)
Specified by:
disposeWorkingMemory in interface InternalRuleBase

getFactHandleFactory

public FactHandleFactory getFactHandleFactory()
See Also:
RuleBase

newFactHandleFactory

public FactHandleFactory newFactHandleFactory()
Specified by:
newFactHandleFactory in interface InternalRuleBase

getPackages

public Package[] getPackages()
Specified by:
getPackages in interface RuleBase

getGlobals

public java.util.Map getGlobals()
Specified by:
getGlobals in interface InternalRuleBase

addPackage

public void addPackage(Package newPkg)
                throws PackageIntegrationException
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.

Specified by:
addPackage in interface RuleBase
Parameters:
pkg - The package to add.
Throws:
PackageIntegrationException
RuleIntegrationException - if an error prevents complete construction of the network for the Rule.
FactException
InvalidPatternException

addRule

protected void addRule(Rule rule)
                throws InvalidPatternException
Throws:
InvalidPatternException

removePackage

public void removePackage(java.lang.String packageName)
Specified by:
removePackage in interface RuleBase

removeRule

public void removeRule(java.lang.String packageName,
                       java.lang.String ruleName)
Specified by:
removeRule in interface RuleBase

removeRule

protected abstract void removeRule(Rule rule)

addWorkingMemory

protected void addWorkingMemory(WorkingMemory workingMemory,
                                boolean keepReference)

getWorkingMemories

public java.util.Set getWorkingMemories()
Specified by:
getWorkingMemories in interface RuleBase

getConfiguration

public RuleBaseConfiguration getConfiguration()
Specified by:
getConfiguration in interface InternalRuleBase

newWorkingMemory

public WorkingMemory newWorkingMemory(java.io.InputStream stream)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
Description copied from interface: RuleBase
RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream. If the reference is a byte[] then wrap with new ByteArrayInputStream. By default the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Specified by:
newWorkingMemory in interface RuleBase
Returns:
A serialised initialized WorkingMemory.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
WorkingMemory, DefaultConflictResolver

newWorkingMemory

public WorkingMemory newWorkingMemory(java.io.InputStream stream,
                                      boolean keepReference)
                               throws java.io.IOException,
                                      java.lang.ClassNotFoundException
Description copied from interface: RuleBase
RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream. If the reference is a byte[] then wrap with new ByteArrayInputStream. Optionally the RuleBase retains a weak reference to returned WorkingMemory.

The created WorkingMemory uses the default conflict resolution strategy.

Specified by:
newWorkingMemory in interface RuleBase
Returns:
A serialised initialized WorkingMemory.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
WorkingMemory, DefaultConflictResolver