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

AbstractRuleBase (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.common
Class AbstractRuleBase

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

public abstract class AbstractRuleBase
extends Object
implements InternalRuleBase, Externalizable

Implementation of RuleBase.

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

Field Summary
protected  RuleBaseConfiguration config
           
protected  FactHandleFactory factHandleFactory
          The fact handle factory.
protected  Map globals
           
protected  String id
           
protected  CompositePackageClassLoader packageClassLoader
           
protected  Map pkgs
           
protected  Map processes
           
protected  ObjectHashSet statefulSessions
          WeakHashMap to keep references of WorkingMemories but allow them to be garbage collected
protected  int workingMemoryCounter
           
 
Fields inherited from interface org.drools.RuleBase
LEAPS, RETEOO
 
Constructor Summary
AbstractRuleBase()
          Default constructor - for Externalizable.
AbstractRuleBase(String id, RuleBaseConfiguration config, FactHandleFactory factHandleFactory)
          Construct.
 
Method Summary
 void addPackage(Package newPkg)
          Add a Package to the network.
 void addProcess(IProcess process)
           
protected  void addRule(Rule rule)
           
protected  void addStatefulSession(StatefulSession statefulSession)
           
 void disposeStatefulSession(StatefulSession statefulSession)
           
 void doReadExternal(ObjectInput stream, Object[] objects)
          Handles the read serialization of the Package.
 void doWriteExternal(ObjectOutput stream, Object[] objects)
          Handles the write serialization of the Package.
 RuleBaseConfiguration getConfiguration()
           
 FactHandleFactory getFactHandleFactory()
           
 Map getGlobals()
           
 String getId()
           
 Package[] getPackages()
           
 IProcess getProcess(String id)
           
 IProcess[] getProcesses()
           
 StatefulSession[] getStatefulSessions()
           
 InternalWorkingMemory[] getWorkingMemories()
           
 FactHandleFactory newFactHandleFactory()
           
 StatefulSession newStatefulSession()
          Create a new WorkingMemory session for this RuleBase.
abstract  StatefulSession newStatefulSession(boolean keepReference)
          Create a new WorkingMemory session for this RuleBase.
 StatefulSession newStatefulSession(InputStream stream)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 StatefulSession newStatefulSession(InputStream stream, boolean keepReference)
          RuleBases handle the returning of a Serialized WorkingMemory pass as an InputStream.
 void removePackage(String packageName)
           
 void removeProcess(String id)
           
protected abstract  void removeRule(Rule rule)
           
 void removeRule(String packageName, 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, retractObject
 
Methods inherited from interface org.drools.RuleBase
newStatelessSession
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Field Detail

id

protected String id

workingMemoryCounter

protected int workingMemoryCounter

config

protected RuleBaseConfiguration config

pkgs

protected Map pkgs

processes

protected Map processes

packageClassLoader

protected transient CompositePackageClassLoader packageClassLoader

factHandleFactory

protected FactHandleFactory factHandleFactory
The fact handle factory.


globals

protected Map globals

statefulSessions

protected transient ObjectHashSet statefulSessions
WeakHashMap to keep references of WorkingMemories but allow them to be garbage collected

Constructor Detail

AbstractRuleBase

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


AbstractRuleBase

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

Parameters:
rete - The rete network.
Method Detail

doWriteExternal

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

Throws:
IOException

doReadExternal

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

Throws:
IOException
ClassNotFoundException

getId

public String getId()
Specified by:
getId in interface InternalRuleBase
Returns:
the id

newStatefulSession

public StatefulSession newStatefulSession()
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:
newStatefulSession in interface RuleBase
Returns:
A newly initialized WorkingMemory.
See Also:
RuleBase

newStatefulSession

public abstract StatefulSession newStatefulSession(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:
newStatefulSession in interface RuleBase
Returns:
A newly initialized WorkingMemory.
See Also:
RuleBase

disposeStatefulSession

public void disposeStatefulSession(StatefulSession statefulSession)
Specified by:
disposeStatefulSession in interface InternalRuleBase

getFactHandleFactory

public FactHandleFactory getFactHandleFactory()
See Also:
RuleBase

newFactHandleFactory

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

getProcesses

public IProcess[] getProcesses()

getPackages

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

getGlobals

public 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(String packageName)
Specified by:
removePackage in interface RuleBase

removeRule

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

removeRule

protected abstract void removeRule(Rule rule)

addProcess

public void addProcess(IProcess process)
Specified by:
addProcess in interface RuleBase

removeProcess

public void removeProcess(String id)
Specified by:
removeProcess in interface RuleBase

getProcess

public IProcess getProcess(String id)
Specified by:
getProcess in interface RuleBase

addStatefulSession

protected void addStatefulSession(StatefulSession statefulSession)

getStatefulSessions

public StatefulSession[] getStatefulSessions()
Specified by:
getStatefulSessions in interface RuleBase

getWorkingMemories

public InternalWorkingMemory[] getWorkingMemories()

getConfiguration

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

newStatefulSession

public StatefulSession newStatefulSession(InputStream stream)
                                   throws IOException,
                                          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:
newStatefulSession in interface RuleBase
Returns:
A serialised initialized WorkingMemory.
Throws:
IOException
ClassNotFoundException
See Also:
WorkingMemory, DefaultConflictResolver

newStatefulSession

public StatefulSession newStatefulSession(InputStream stream,
                                          boolean keepReference)
                                   throws IOException,
                                          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:
newStatefulSession in interface RuleBase
Returns:
A serialised initialized WorkingMemory.
Throws:
IOException
ClassNotFoundException
See Also:
WorkingMemory, DefaultConflictResolver


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.