org.drools.audit
Class WorkingMemoryFileLogger

java.lang.Object
  extended by org.drools.audit.WorkingMemoryLogger
      extended by org.drools.audit.WorkingMemoryFileLogger
All Implemented Interfaces:
Externalizable, Serializable, EventListener, AgendaEventListener, org.drools.event.process.ProcessEventListener, RuleBaseEventListener, WorkingMemoryEventListener
Direct Known Subclasses:
ThreadedWorkingMemoryFileLogger

public class WorkingMemoryFileLogger
extends WorkingMemoryLogger

A logger of events generated by a working memory. It stores its information in a file that can be specified. All the events logged are written to the file when the writeToDisk() method is invoked. The log will contain all the events logged serialized to XML using XStream. Every time a new logger is created, the old event log will be overwritten. TODO: make this class more scalable, for example - logging to several files if log becomes too large - automatically write updates to file at certain time intervals - ...

See Also:
Serialized Form

Field Summary
protected  boolean terminate
           
 
Constructor Summary
WorkingMemoryFileLogger()
           
WorkingMemoryFileLogger(org.drools.event.KnowledgeRuntimeEventManager session)
           
WorkingMemoryFileLogger(WorkingMemory workingMemory)
          Creates a new WorkingMemoryFileLogger for the given working memory.
 
Method Summary
 void logEventCreated(LogEvent logEvent)
          This method is invoked every time a new log event is created.
 void readExternal(ObjectInput in)
           
 void setFileName(String fileName)
          Sets the name of the file the events are logged in.
 void setMaxEventsInMemory(int maxEventsInMemory)
          Sets the maximum number of log events that are allowed in memory.
 void setSplit(boolean split)
           
 void stop()
           
 void writeExternal(ObjectOutput out)
           
 void writeToDisk()
          All events in the log are written to file.
 
Methods inherited from class org.drools.audit.WorkingMemoryLogger
activationCancelled, activationCreated, addFilter, afterActivationFired, afterFunctionRemoved, afterNodeLeft, afterNodeTriggered, afterPackageAdded, afterPackageRemoved, afterProcessAdded, afterProcessCompleted, afterProcessRemoved, afterProcessStarted, afterRuleAdded, afterRuleBaseLocked, afterRuleBaseUnlocked, afterRuleFlowGroupActivated, afterRuleFlowGroupDeactivated, afterRuleRemoved, afterVariableChanged, agendaGroupPopped, agendaGroupPushed, beforeActivationFired, beforeFunctionRemoved, beforeNodeLeft, beforeNodeTriggered, beforePackageAdded, beforePackageRemoved, beforeProcessAdded, beforeProcessCompleted, beforeProcessRemoved, beforeProcessStarted, beforeRuleAdded, beforeRuleBaseLocked, beforeRuleBaseUnlocked, beforeRuleFlowGroupActivated, beforeRuleFlowGroupDeactivated, beforeRuleRemoved, beforeVariableChanged, clearFilters, objectInserted, objectRetracted, objectUpdated, removeFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

terminate

protected boolean terminate
Constructor Detail

WorkingMemoryFileLogger

public WorkingMemoryFileLogger()

WorkingMemoryFileLogger

public WorkingMemoryFileLogger(WorkingMemory workingMemory)
Creates a new WorkingMemoryFileLogger for the given working memory.

Parameters:
workingMemoryEventManager -

WorkingMemoryFileLogger

public WorkingMemoryFileLogger(org.drools.event.KnowledgeRuntimeEventManager session)
Method Detail

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class WorkingMemoryLogger
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class WorkingMemoryLogger
Throws:
IOException

setFileName

public void setFileName(String fileName)
Sets the name of the file the events are logged in. No extensions should be given since .log is automatically appended to the file name. The default is an event.log file in the current working directory. This can be a path relative to the current working directory (e.g. "mydir/subDir/myLogFile"), or an absolute path (e.g. "C:/myLogFile").

Parameters:
fileName - The name of the file the events should be logged in.

writeToDisk

public void writeToDisk()
All events in the log are written to file. The log is automatically cleared afterwards.


setMaxEventsInMemory

public void setMaxEventsInMemory(int maxEventsInMemory)
Sets the maximum number of log events that are allowed in memory. If this number is reached, all events are written to file. The default is 1000.

Parameters:
maxEventsInMemory - The maximum number of events in memory.

logEventCreated

public void logEventCreated(LogEvent logEvent)
Description copied from class: WorkingMemoryLogger
This method is invoked every time a new log event is created. Subclasses should implement this method and store the event, like for example log to a file or database.

Specified by:
logEventCreated in class WorkingMemoryLogger
See Also:
WorkingMemoryLogger

setSplit

public void setSplit(boolean split)

stop

public void stop()


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