[jboss-svn-commits] JBL Code SVN: r17695 - in labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools: common and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 10 17:12:57 EST 2008
Author: fmeyer
Date: 2008-01-10 17:12:57 -0500 (Thu, 10 Jan 2008)
New Revision: 17695
Modified:
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
Log:
SOA-317 - OutOfMemory with the use of WorkingMemoryFileLogger JBRULES-1325
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryFileLogger.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -84,18 +84,20 @@
* The log is automatically cleared afterwards.
*/
public void writeToDisk() {
+ ObjectOutputStream out = null;
try {
final XStream xstream = new XStream();
- final ObjectOutputStream out = xstream.createObjectOutputStream( new FileWriter( this.fileName + (this.nbOfFile == 0 ? ".log" : this.nbOfFile + ".log"),
+ out = xstream.createObjectOutputStream( new FileWriter( this.fileName + (this.nbOfFile == 0 ? ".log" : this.nbOfFile + ".log"),
false ) );
out.writeObject( this.events );
- out.close();
this.nbOfFile++;
clear();
} catch ( final FileNotFoundException exc ) {
throw new RuntimeException( "Could not create the log file. Please make sure that directory that the log file should be placed in does exist." );
} catch ( final Throwable t ) {
t.printStackTrace( System.err );
+ } finally {
+ if( out != null ) { try { out.close(); } catch(Exception e) {} }
}
}
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryInMemoryLogger.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -23,14 +23,6 @@
import org.drools.WorkingMemory;
import org.drools.audit.event.LogEvent;
-import org.drools.event.AfterPackageAddedEvent;
-import org.drools.event.AfterPackageRemovedEvent;
-import org.drools.event.AfterRuleAddedEvent;
-import org.drools.event.AfterRuleRemovedEvent;
-import org.drools.event.BeforePackageAddedEvent;
-import org.drools.event.BeforePackageRemovedEvent;
-import org.drools.event.BeforeRuleAddedEvent;
-import org.drools.event.BeforeRuleRemovedEvent;
import com.thoughtworks.xstream.XStream;
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/audit/WorkingMemoryLogger.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -90,7 +90,6 @@
RuleBaseEventListener {
private final List filters = new ArrayList();
- private WorkingMemoryEventManager workingMemoryEventManager;
/**
* Creates a new working memory logger for the given working memory.
@@ -98,11 +97,10 @@
* @param workingMemory
*/
public WorkingMemoryLogger(final WorkingMemoryEventManager workingMemoryEventManager) {
- this.workingMemoryEventManager = workingMemoryEventManager;
- this.workingMemoryEventManager.addEventListener( (WorkingMemoryEventListener) this );
- this.workingMemoryEventManager.addEventListener( (AgendaEventListener) this );
- this.workingMemoryEventManager.addEventListener( (RuleFlowEventListener) this );
- this.workingMemoryEventManager.addEventListener( (RuleBaseEventListener) this );
+ workingMemoryEventManager.addEventListener( (WorkingMemoryEventListener) this );
+ workingMemoryEventManager.addEventListener( (AgendaEventListener) this );
+ workingMemoryEventManager.addEventListener( (RuleFlowEventListener) this );
+ workingMemoryEventManager.addEventListener( (RuleBaseEventListener) this );
}
/**
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -25,6 +25,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -119,6 +120,8 @@
protected AgendaEventSupport agendaEventSupport = new AgendaEventSupport();
protected RuleFlowEventSupport ruleFlowEventSupport = new RuleFlowEventSupport();
+
+ protected List __ruleBaseEventListeners = new LinkedList();
/** The <code>RuleBase</code> with which this memory is associated. */
protected transient InternalRuleBase ruleBase;
@@ -313,6 +316,7 @@
try {
this.lock.lock();
this.ruleBase.addEventListener( listener );
+ this.__ruleBaseEventListeners.add( listener );
} finally {
this.lock.unlock();
}
@@ -321,7 +325,7 @@
public List getRuleBaseEventListeners() {
try {
this.lock.lock();
- return this.ruleBase.getRuleBaseEventListeners();
+ return Collections.unmodifiableList( this.__ruleBaseEventListeners );
} finally {
this.lock.unlock();
}
@@ -331,6 +335,7 @@
try {
this.lock.lock();
this.ruleBase.removeEventListener( listener );
+ this.__ruleBaseEventListeners.remove( listener );
} finally {
this.lock.unlock();
}
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/AgendaEventSupport.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -146,4 +146,8 @@
workingMemory );
}
}
+
+ public void reset() {
+ this.listeners.clear();
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/RuleFlowEventSupport.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -116,4 +116,8 @@
}
}
+ public void reset() {
+ this.listeners.clear();
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/event/WorkingMemoryEventSupport.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -118,4 +118,8 @@
}
}
+ public void reset() {
+ this.listeners.clear();
+ }
+
}
\ No newline at end of file
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-01-10 20:04:26 UTC (rev 17694)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/reteoo/ReteooStatefulSession.java 2008-01-10 22:12:57 UTC (rev 17695)
@@ -2,6 +2,7 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.drools.FactHandle;
@@ -14,6 +15,7 @@
import org.drools.concurrent.Future;
import org.drools.concurrent.RetractObject;
import org.drools.concurrent.UpdateObject;
+import org.drools.event.RuleBaseEventListener;
import org.drools.spi.AgendaFilter;
import org.drools.spi.RuleBaseUpdateListener;
import org.drools.spi.RuleBaseUpdateListenerFactory;
@@ -77,6 +79,12 @@
public void dispose() {
this.ruleBase.disposeStatefulSession( this );
+ this.workingMemoryEventSupport.reset();
+ this.agendaEventSupport.reset();
+ this.ruleFlowEventSupport.reset();
+ for( Iterator it = this.__ruleBaseEventListeners.iterator(); it.hasNext(); ) {
+ this.ruleBase.removeEventListener( (RuleBaseEventListener) it.next() );
+ }
this.executor.shutDown();
}
More information about the jboss-svn-commits
mailing list