org.drools.agent
Class ChangeSetHelperImpl

java.lang.Object
  extended by org.drools.agent.ChangeSetHelperImpl

public class ChangeSetHelperImpl
extends Object

Helper class to programmatically add and remove Resources from a change-set. This class also has the possibility to apply its internal change-set to a kagent.


Constructor Summary
ChangeSetHelperImpl()
          Creates a new instance of ChangeSetHelperImpl
 
Method Summary
 void addModifiedResource(org.drools.io.Resource resource)
          Adds a Resource as modified.
 void addNewResource(org.drools.io.Resource resource)
          Adds a new Resource to the internal ChangeSet
 void addRemovedResource(org.drools.io.Resource resource)
          Adds a Resource as removed.
 void applyChangeSet(org.drools.agent.KnowledgeAgent kagent)
          Synchronously apply the internal ChangeSet to a KnowledgeAgent.
 ChangeSetImpl getChangeSet()
          Returns the internal ChangeSet
 void reset()
          Reset the internal ChangeSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeSetHelperImpl

public ChangeSetHelperImpl()
Creates a new instance of ChangeSetHelperImpl

Method Detail

addNewResource

public void addNewResource(org.drools.io.Resource resource)
Adds a new Resource to the internal ChangeSet

Parameters:
resource - the resource to be added as New

addModifiedResource

public void addModifiedResource(org.drools.io.Resource resource)
Adds a Resource as modified. This method should only be used if ResourceChangeScanner is not running. If ResourceChangeScanner and ResourceChangeNotifier are running, the kagent is going to be automatically notified when the resource changes.

Parameters:
resource - the resource to be added as Modified

addRemovedResource

public void addRemovedResource(org.drools.io.Resource resource)
Adds a Resource as removed. Use this method if you want to de-subscribe an agent from a Resource.

Parameters:
resource - the resource to be added as Removed

applyChangeSet

public void applyChangeSet(org.drools.agent.KnowledgeAgent kagent)
Synchronously apply the internal ChangeSet to a KnowledgeAgent. If the internal ChangeSet is empty, the agent is not even bothered. If the agent fails while compiling the resources of the ChangeSet, a RuntimeException is thrown. After the ChangeSet is applied, it is reseted. The Knowledge Agent should have added the corresponding listeners to monitor the resources by its own.

Parameters:
kagent -
Throws:
RuntimeException - if the agent fails while compiling the resources.

reset

public void reset()
Reset the internal ChangeSet


getChangeSet

public ChangeSetImpl getChangeSet()
Returns the internal ChangeSet

Returns:
the internal ChangeSet


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