[jboss-svn-commits] JBL Code SVN: r16457 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 9 02:32:40 EST 2007


Author: michael.neale at jboss.com
Date: 2007-11-09 02:32:40 -0500 (Fri, 09 Nov 2007)
New Revision: 16457

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
Log:
JBRULES-1317 reloadPackageCompilationData was not being reset after executing queued actions

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-11-09 06:45:27 UTC (rev 16456)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-11-09 07:32:40 UTC (rev 16457)
@@ -2,13 +2,13 @@
 
 /*
  * Copyright 2005 JBoss Inc
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -59,10 +59,10 @@
 
 /**
  * Implementation of <code>RuleBase</code>.
- * 
+ *
  * @author <a href="mailto:bob at werken.com">bob mcwhirter</a>
- * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a> 
- * 
+ * @author <a href="mailto:mark.proctor at jboss.com">Mark Proctor</a>
+ *
  * @version $Id: RuleBaseImpl.java,v 1.5 2005/08/14 22:44:12 mproctor Exp $
  */
 abstract public class AbstractRuleBase
@@ -111,12 +111,12 @@
 
     // lock for entire rulebase, used for dynamic updates
     protected final ReentrantLock                   lock                         = new ReentrantLock();
-    
+
     private int                                  additionsSinceLock;
     private int                                  removalsSinceLock;
 
     /**
-     * Default constructor - for Externalizable. This should never be used by a user, as it 
+     * Default constructor - for Externalizable. This should never be used by a user, as it
      * will result in an invalid state for the instance.
      */
     public AbstractRuleBase() {
@@ -129,7 +129,7 @@
 
     /**
      * Construct.
-     * 
+     *
      * @param rete
      *            The rete network.
      */
@@ -165,9 +165,9 @@
     /**
      * 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.
-     * 
+     *
      */
-    public void doWriteExternal(final ObjectOutput stream) throws IOException {        
+    public void doWriteExternal(final ObjectOutput stream) throws IOException {
         stream.writeObject( this.pkgs );
 
         // Rules must be restored by an ObjectInputStream that can resolve using a given ClassLoader to handle seaprately by storing as
@@ -180,10 +180,10 @@
         out.writeObject( this.factHandleFactory );
         out.writeObject( this.globals );
         out.writeObject( this.config );
-        
+
         this.eventSupport.removeEventListener( RuleBaseEventListener.class );
-        out.writeObject( this.eventSupport );    
-        
+        out.writeObject( this.eventSupport );
+
         stream.writeObject( bos.toByteArray() );
     }
 
@@ -191,11 +191,11 @@
      * 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.
-     * 
+     *
      */
     public void doReadExternal(final ObjectInput stream) throws IOException,
                                                       ClassNotFoundException {
-        // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules        
+        // PackageCompilationData must be restored before Rules as it has the ClassLoader needed to resolve the generated code references in Rules
         this.pkgs = (Map) stream.readObject();
 
         if ( stream instanceof DroolsObjectInputStream ) {
@@ -291,7 +291,7 @@
 
     public Map getAgendaGroupRuleTotals() {
         return this.agendaGroupRuleTotals;
-    }        
+    }
 
     public int getAdditionsSinceLock() {
         return additionsSinceLock;
@@ -304,12 +304,12 @@
     public void lock() {
         this.additionsSinceLock = 0;
         this.removalsSinceLock = 0;
-        
+
         this.eventSupport.fireBeforeRuleBaseLocked();
         this.lock.lock();
 
-        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
-        // in the working memory array 
+        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1
+        // in the working memory array
         this.lastAquiredLock = 0;
 
         this.wms = getWorkingMemories();
@@ -326,9 +326,9 @@
     public void unlock() {
         this.eventSupport.fireBeforeRuleBaseUnlocked();
 
-        // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
+        // Iterate each workingMemory and attempt to fire any rules, that were activated as a result
 
-        // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
+        // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0.
         for ( this.lastAquiredLock--; this.lastAquiredLock > -1; this.lastAquiredLock-- ) {
             this.wms[this.lastAquiredLock].getLock().unlock();
         }
@@ -337,7 +337,7 @@
 
         this.eventSupport.fireAfterRuleBaseUnlocked();
 
-        this.wms = null;      
+        this.wms = null;
     }
 
     /**
@@ -345,11 +345,11 @@
      * <code>Package</code> adding Each individual <code>Rule</code> to the
      * network. Before update network each referenced <code>WorkingMemory</code>
      * is locked.
-     * 
+     *
      * @param pkg
      *            The package to add.
-     * @throws PackageIntegrationException 
-     * 
+     * @throws PackageIntegrationException
+     *
      * @throws RuleIntegrationException
      *             if an error prevents complete construction of the network for
      *             the <code>Rule</code>.
@@ -427,7 +427,7 @@
 
     /**
      * Merge a new package with an existing package.
-     * Most of the work is done by the concrete implementations, 
+     * Most of the work is done by the concrete implementations,
      * but this class does some work (including combining imports, compilation data, globals,
      * and the actual Rule objects into the package).
      */
@@ -518,7 +518,7 @@
                 doUnlock = true;
             }
             this.removalsSinceLock++;
-            
+
             this.eventSupport.fireBeforePackageRemoved( pkg );
 
             final Rule[] rules = pkg.getRules();
@@ -530,7 +530,7 @@
 
             this.packageClassLoader.removeClassLoader( pkg.getPackageCompilationData().getClassLoader() );
 
-            // getting the list of referenced globals 
+            // getting the list of referenced globals
             final Set referencedGlobals = new HashSet();
             for ( final Iterator it = this.pkgs.values().iterator(); it.hasNext(); ) {
                 final org.drools.rule.Package pkgref = (org.drools.rule.Package) it.next();
@@ -596,7 +596,7 @@
             }
             this.reloadPackageCompilationData.addPackageCompilationData( compilationData );
 
-            // only unlock if it had been acquired implicitely                
+            // only unlock if it had been acquired implicitely
             if ( doUnlock ) {
                 unlock();
             }
@@ -704,7 +704,7 @@
         synchronized ( this.pkgs ) {
             ((InternalWorkingMemory) session).setRuleBase( this );
             ((InternalWorkingMemory) session).setId( ( nextWorkingMemoryCounter() ) );
-            
+
             ExecutorService executor = ExecutorServiceFactory.createExecutorService(  this.config.getExecutorService() );
 
             executor.setCommandExecutor( new CommandExecutor( session ) );
@@ -712,10 +712,10 @@
             if ( keepReference ) {
                 addStatefulSession( session );
                 for( Iterator it = session.getRuleBaseUpdateListeners().iterator(); it.hasNext(); ) {
-                    addEventListener( (RuleBaseEventListener) it.next() ); 
+                    addEventListener( (RuleBaseEventListener) it.next() );
                 }
-            }     
-            
+            }
+
             return (StatefulSession) session;
         }
     }
@@ -738,7 +738,9 @@
         synchronized ( this.pkgs ) {
             if ( this.reloadPackageCompilationData != null ) {
                 this.reloadPackageCompilationData.execute( this );
+                this.reloadPackageCompilationData = null;
             }
+
         }
     }
 




More information about the jboss-svn-commits mailing list