[jboss-svn-commits] JBL Code SVN: r23767 - in labs/jbossrules/trunk: drools-compiler/src/test/java/org/drools/integrationtests and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 6 20:36:24 EST 2008


Author: mark.proctor at jboss.com
Date: 2008-11-06 20:36:23 -0500 (Thu, 06 Nov 2008)
New Revision: 23767

Added:
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceException.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/DefaultConsequenceExceptionHandler.java
Modified:
   labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceExceptionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
   labs/jbossrules/trunk/drools-core/src/main/resources/META-INF/drools.default.rulebase.conf
Log:
JBRULES-1734 Drools API 
-Refactoring to expose ConsequenceExceptionHandler

Added: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceException.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceException.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceException.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -0,0 +1,18 @@
+package org.drools.runtime.rule;
+
+import org.drools.definition.rule.Rule;
+
+public class ConsequenceException extends RuntimeException {
+    private Rule              rule;
+    
+    public ConsequenceException(final Throwable rootCause,
+                                final Rule rule) {
+        super( rootCause );
+        this.rule = rule;
+    }
+    
+    public Rule getRule() {
+        return this.rule;
+    }
+    
+}

Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceExceptionHandler.java	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/runtime/rule/ConsequenceExceptionHandler.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -1,7 +1,5 @@
 package org.drools.runtime.rule;
 
-import java.io.Externalizable;
-
-public interface ConsequenceExceptionHandler extends Externalizable {
+public interface ConsequenceExceptionHandler {
     void handleException(Activation activation, WorkingMemory workingMemory, Exception exception);
 }

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -83,6 +83,7 @@
 import org.drools.audit.WorkingMemoryFileLogger;
 import org.drools.audit.WorkingMemoryInMemoryLogger;
 import org.drools.common.AbstractWorkingMemory;
+import org.drools.common.DefaultAgenda;
 import org.drools.common.InternalFactHandle;
 import org.drools.compiler.DescrBuildError;
 import org.drools.compiler.DrlParser;
@@ -1422,8 +1423,7 @@
                       ((List) session.getGlobal( "list" )).size() );
     }
 
-    // @FIXME
-    public void FIXME_testBigDecimalWithFromAndEval() throws Exception {
+    public void testBigDecimalWithFromAndEval() throws Exception {
         String rule = "package org.test;\n";
         rule += "rule \"Test Rule\"\n";
         rule += "when\n";
@@ -2204,7 +2204,8 @@
         try {
             workingMemory.fireAllRules();
             fail( "Should throw an Exception from the Consequence" );
-        } catch ( final Exception e ) {
+        } catch ( final org.drools.runtime.rule.ConsequenceException e ) {
+            assertEquals( "Throw Consequence Exception", e.getRule().getName() );
             assertEquals( "this should throw an exception",
                           e.getCause().getMessage() );
         }
@@ -2216,8 +2217,7 @@
         final Package pkg = builder.getPackage();
 
         RuleBaseConfiguration conf = new RuleBaseConfiguration();
-        CustomConsequenceExceptionHandler handler = new CustomConsequenceExceptionHandler();
-        conf.setConsequenceExceptionHandler( handler );
+        conf.setConsequenceExceptionHandler( CustomConsequenceExceptionHandler.class.getName() );
 
         RuleBase ruleBase = getRuleBase( conf );
         ruleBase.addPackage( pkg );
@@ -2230,7 +2230,9 @@
 
         workingMemory.fireAllRules();
 
-        assertTrue( ((CustomConsequenceExceptionHandler) ((ReteooRuleBase) ruleBase).getConfiguration().getConsequenceExceptionHandler()).isCalled() );
+        
+        
+        assertTrue( ((CustomConsequenceExceptionHandler) ((DefaultAgenda) workingMemory.getAgenda()).getConsequenceExceptionHandler()).isCalled() );
     }
 
     public static class CustomConsequenceExceptionHandler
@@ -2239,8 +2241,8 @@
 
         private boolean called;
 
-        public void handleException(Activation activation,
-                                    WorkingMemory workingMemory,
+        public void handleException(org.drools.spi.Activation activation,
+                                    org.drools.WorkingMemory workingMemory,
                                     Exception exception) {
             this.called = true;
         }

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/RuleBaseConfiguration.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -116,7 +116,7 @@
     private AssertBehaviour                assertBehaviour;
     private LogicalOverride                logicalOverride;
     private String                         executorService;
-    private ConsequenceExceptionHandler    consequenceExceptionHandler;
+    private String                         consequenceExceptionHandler;
     private String                         ruleBaseUpdateHandler;
 
     private EventProcessingMode            eventProcessingMode;
@@ -186,7 +186,7 @@
         assertBehaviour = (AssertBehaviour) in.readObject();
         logicalOverride = (LogicalOverride) in.readObject();
         executorService = (String) in.readObject();
-        consequenceExceptionHandler = (ConsequenceExceptionHandler) in.readObject();
+        consequenceExceptionHandler = (String) in.readObject();
         ruleBaseUpdateHandler = (String) in.readObject();
         conflictResolver = (ConflictResolver) in.readObject();
         processNodeInstanceFactoryRegistry = (NodeInstanceFactoryRegistry) in.readObject();
@@ -235,7 +235,7 @@
         init( classLoader,
               null );
     }
-    
+
     public boolean isEmpty(String value) {
         if ( value == null || value.trim().length() == 0 ) {
             return true;
@@ -253,44 +253,44 @@
         if ( name.equals( "drools.sequential.agenda" ) ) {
             setSequentialAgenda( SequentialAgenda.determineSequentialAgenda( isEmpty( value ) ? "sequential" : value ) );
         } else if ( name.equals( "drools.sequential" ) ) {
-            setSequential( isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setSequential( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.maintainTms" ) ) {
-            setMaintainTms( isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setMaintainTms( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.removeIdentities" ) ) {
-            setRemoveIdentities( isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setRemoveIdentities( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.shareAlphaNodes" ) ) {
-            setShareAlphaNodes( isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setShareAlphaNodes( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.shareBetaNodes" ) ) {
-            setShareBetaNodes( isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setShareBetaNodes( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.alphaNodeHashingThreshold" ) ) {
-            setAlphaNodeHashingThreshold( isEmpty( value) ? 3 : Integer.parseInt( value ));
+            setAlphaNodeHashingThreshold( isEmpty( value ) ? 3 : Integer.parseInt( value ) );
         } else if ( name.equals( "drools.compositeKeyDepth" ) ) {
-            setCompositeKeyDepth( isEmpty( value) ? 3 : Integer.parseInt( value ) );
+            setCompositeKeyDepth( isEmpty( value ) ? 3 : Integer.parseInt( value ) );
         } else if ( name.equals( "drools.indexLeftBetaMemory" ) ) {
-            setIndexLeftBetaMemory( isEmpty( value) ? true : Boolean.valueOf( value ) );
+            setIndexLeftBetaMemory( isEmpty( value ) ? true : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.indexRightBetaMemory" ) ) {
-            setIndexRightBetaMemory( isEmpty( value) ? true : Boolean.valueOf( value ) );
+            setIndexRightBetaMemory( isEmpty( value ) ? true : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.assertBehaviour" ) ) {
-            setAssertBehaviour( AssertBehaviour.determineAssertBehaviour( isEmpty( value) ? "identity" : value ) );
+            setAssertBehaviour( AssertBehaviour.determineAssertBehaviour( isEmpty( value ) ? "identity" : value ) );
         } else if ( name.equals( "drools.logicalOverride" ) ) {
-            setLogicalOverride( LogicalOverride.determineLogicalOverride( isEmpty( value) ? "discard" : value ) );
+            setLogicalOverride( LogicalOverride.determineLogicalOverride( isEmpty( value ) ? "discard" : value ) );
         } else if ( name.equals( "drools.executorService" ) ) {
-            setExecutorService( isEmpty( value) ? "org.drools.concurrent.DefaultExecutorService" : value );
+            setExecutorService( isEmpty( value ) ? "org.drools.concurrent.DefaultExecutorService" : value );
         } else if ( name.equals( "drools.consequenceExceptionHandler" ) ) {
-            setConsequenceExceptionHandler( RuleBaseConfiguration.determineConsequenceExceptionHandler( isEmpty( value) ? "org.drools.base.DefaultConsequenceExceptionHandler" : value ) );
+            setConsequenceExceptionHandler( isEmpty( value ) ? "org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler" : value );
         } else if ( name.equals( "drools.ruleBaseUpdateHandler" ) ) {
-            setRuleBaseUpdateHandler( isEmpty( value) ? "org.drools.base.FireAllRulesRuleBaseUpdateListener" : value );
+            setRuleBaseUpdateHandler( isEmpty( value ) ? "org.drools.base.FireAllRulesRuleBaseUpdateListener" : value );
         } else if ( name.equals( "drools.conflictResolver" ) ) {
-            setConflictResolver( RuleBaseConfiguration.determineConflictResolver( isEmpty( value) ? "org.drools.conflict.DepthConflictResolver" : value ) );
-        } else if ( name.equals( "drools.conflictResolver" ) ) {
-            setAdvancedProcessRuleIntegration(  isEmpty( value) ? false : Boolean.valueOf( value ) );
+            setConflictResolver( RuleBaseConfiguration.determineConflictResolver( isEmpty( value ) ? "org.drools.conflict.DepthConflictResolver" : value ) );
+        } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) {
+            setAdvancedProcessRuleIntegration( isEmpty( value ) ? false : Boolean.valueOf( value ) );
         } else if ( name.equals( "drools.multithreadEvaluation" ) ) {
-            setMultithreadEvaluation(  isEmpty( value) ? false : Boolean.valueOf( value ) );
-        }  else if ( name.equals( "drools.maxThreads" ) ) {
-            setMaxThreads(  isEmpty( value) ? -1 : Integer.parseInt( value ) );
+            setMultithreadEvaluation( isEmpty( value ) ? false : Boolean.valueOf( value ) );
+        } else if ( name.equals( "drools.maxThreads" ) ) {
+            setMaxThreads( isEmpty( value ) ? -1 : Integer.parseInt( value ) );
         } else if ( name.equals( "drools.eventProcessingMode" ) ) {
-            setEventProcessingMode( EventProcessingMode.determineAssertBehaviour( isEmpty( value) ? "cloud" : value ) );
-        } 
+            setEventProcessingMode( EventProcessingMode.determineAssertBehaviour( isEmpty( value ) ? "cloud" : value ) );
+        }
     }
 
     public String getProperty(String name) {
@@ -330,16 +330,16 @@
             return getRuleBaseUpdateHandler();
         } else if ( name.equals( "drools.conflictResolver" ) ) {
             return getConflictResolver().getClass().getName();
-        } else if ( name.equals( "drools.conflictResolver" ) ) {
+        } else if ( name.equals( "drools.advancedProcessRuleIntegration" ) ) {
             return Boolean.toString( isAdvancedProcessRuleIntegration() );
         } else if ( name.equals( "drools.multithreadEvaluation" ) ) {
             Boolean.toString( isMultithreadEvaluation() );
-        }  else if ( name.equals( "drools.maxThreads" ) ) {
+        } else if ( name.equals( "drools.maxThreads" ) ) {
             return Integer.toString( getMaxThreads() );
         } else if ( name.equals( "drools.eventProcessingMode" ) ) {
             return getEventProcessingMode().toExternalForm();
-        } 
-        
+        }
+
         return null;
     }
 
@@ -412,8 +412,8 @@
         setExecutorService( this.chainedProperties.getProperty( "drools.executorService",
                                                                 "org.drools.concurrent.DefaultExecutorService" ) );
 
-        setConsequenceExceptionHandler( RuleBaseConfiguration.determineConsequenceExceptionHandler( this.chainedProperties.getProperty( "drools.consequenceExceptionHandler",
-                                                                                                                                        "org.drools.base.DefaultConsequenceExceptionHandler" ) ) );
+        setConsequenceExceptionHandler( this.chainedProperties.getProperty( "drools.consequenceExceptionHandler",
+                                                                            "org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler" ) );
 
         setRuleBaseUpdateHandler( this.chainedProperties.getProperty( "drools.ruleBaseUpdateHandler",
                                                                       "org.drools.base.FireAllRulesRuleBaseUpdateListener" ) );
@@ -578,11 +578,11 @@
         this.executorService = executorService;
     }
 
-    public ConsequenceExceptionHandler getConsequenceExceptionHandler() {
+    public String getConsequenceExceptionHandler() {
         return consequenceExceptionHandler;
     }
 
-    public void setConsequenceExceptionHandler(ConsequenceExceptionHandler consequenceExceptionHandler) {
+    public void setConsequenceExceptionHandler(String consequenceExceptionHandler) {
         checkCanChange(); // throws an exception if a change isn't possible;
         this.consequenceExceptionHandler = consequenceExceptionHandler;
     }
@@ -1097,37 +1097,6 @@
         this.classLoader = classLoader;
     }
 
-    private static ConsequenceExceptionHandler determineConsequenceExceptionHandler(String className) {
-        return (ConsequenceExceptionHandler) instantiateClass( "ConsequenceExceptionHandler",
-                                                               className );
-    }
-
-    private static Object instantiateClass(String type,
-                                           String className) {
-        Class clazz = null;
-        try {
-            clazz = Thread.currentThread().getContextClassLoader().loadClass( className );
-        } catch ( ClassNotFoundException e ) {
-        }
-
-        if ( clazz == null ) {
-            try {
-                clazz = RuleBaseConfiguration.class.getClassLoader().loadClass( className );
-            } catch ( ClassNotFoundException e ) {
-            }
-        }
-
-        if ( clazz != null ) {
-            try {
-                return clazz.newInstance();
-            } catch ( Exception e ) {
-                throw new IllegalArgumentException( "Unable to instantiate " + type + " '" + className + "'" );
-            }
-        } else {
-            throw new IllegalArgumentException( type + " '" + className + "' not found" );
-        }
-    }
-
     public static class AssertBehaviour
         implements
         Externalizable {
@@ -1185,7 +1154,7 @@
                     throw new IllegalArgumentException( "Illegal enum value '" + this.value + "' for AssertBehaviour" );
             }
         }
-        
+
         public String toExternalForm() {
             return (this.value == 0) ? "identity" : "equality";
         }
@@ -1251,7 +1220,7 @@
             }
             return false;
         }
-        
+
         public String toExternalForm() {
             return (this.value == 0) ? "preserve" : "discard";
         }
@@ -1308,7 +1277,7 @@
                     throw new IllegalArgumentException( "Illegal enum value '" + this.value + "' for SequentialAgenda" );
             }
         }
-        
+
         public String toExternalForm() {
             return (this.value == 0) ? "sequential" : "dynamic";
         }
@@ -1355,10 +1324,10 @@
         public String toString() {
             return string;
         }
-        
+
         public String toExternalForm() {
             return this.string;
-        }        
+        }
 
         public static EventProcessingMode determineAssertBehaviour(String mode) {
             if ( STREAM.getId().equalsIgnoreCase( mode ) ) {

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/DefaultAgenda.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -32,7 +32,10 @@
 import org.drools.base.DefaultKnowledgeHelper;
 import org.drools.base.SequentialKnowledgeHelper;
 import org.drools.common.RuleFlowGroupImpl.DeactivateCallback;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
 import org.drools.reteoo.LeftTuple;
+import org.drools.reteoo.ReteooStatefulSession;
+import org.drools.RuleBaseConfiguration;
 import org.drools.WorkingMemory;
 import org.drools.spi.Activation;
 import org.drools.spi.ActivationGroup;
@@ -43,6 +46,7 @@
 import org.drools.spi.KnowledgeHelper;
 import org.drools.spi.PropagationContext;
 import org.drools.spi.RuleFlowGroup;
+import org.drools.util.ClassUtils;
 import org.drools.util.LinkedListNode;
 
 /**
@@ -73,39 +77,41 @@
     /**
      * 
      */
-    private static final long                serialVersionUID = 400L;
+    private static final long                                   serialVersionUID = 400L;
 
     /** Working memory of this Agenda. */
-    private InternalWorkingMemory            workingMemory;
+    private InternalWorkingMemory                               workingMemory;
 
-    private org.drools.util.LinkedList       scheduledActivations;
+    private org.drools.util.LinkedList                          scheduledActivations;
 
     /** Items time-delayed. */
 
-    private Map<String, InternalAgendaGroup> agendaGroups;
+    private Map<String, InternalAgendaGroup>                    agendaGroups;
 
-    private Map<String, ActivationGroup>     activationGroups;
+    private Map<String, ActivationGroup>                        activationGroups;
 
-    private Map<String, RuleFlowGroup>       ruleFlowGroups;
+    private Map<String, RuleFlowGroup>                          ruleFlowGroups;
 
-    private LinkedList<AgendaGroup>          focusStack;
+    private LinkedList<AgendaGroup>                             focusStack;
 
-    private InternalAgendaGroup              currentModule;
+    private InternalAgendaGroup                                 currentModule;
 
-    private InternalAgendaGroup              main;
+    private InternalAgendaGroup                                 main;
 
-    private AgendaGroupFactory               agendaGroupFactory;
+    private AgendaGroupFactory                                  agendaGroupFactory;
 
-    private KnowledgeHelper                  knowledgeHelper;
+    private KnowledgeHelper                                     knowledgeHelper;
 
-    public int                               activeActivations;
+    public int                                                  activeActivations;
 
-    public int                               dormantActivations;
+    public int                                                  dormantActivations;
 
-    private ConsequenceExceptionHandler      consequenceExceptionHandler;
+    private ConsequenceExceptionHandler                         legacyConsequenceExceptionHandler;
 
-    protected volatile AtomicBoolean         halt             = new AtomicBoolean( false );
+    private org.drools.runtime.rule.ConsequenceExceptionHandler consequenceExceptionHandler;
 
+    protected volatile AtomicBoolean                            halt             = new AtomicBoolean( false );
+
     // ------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------
@@ -154,8 +160,13 @@
 
             this.focusStack.add( this.main );
         }
-
-        this.consequenceExceptionHandler = rb.getConfiguration().getConsequenceExceptionHandler();
+        Object object = ClassUtils.instantiateObject( rb.getConfiguration().getConsequenceExceptionHandler(),
+                                                      rb.getConfiguration().getClassLoader() );
+        if ( object instanceof ConsequenceExceptionHandler ) {
+            this.legacyConsequenceExceptionHandler = (ConsequenceExceptionHandler) object;
+        } else {
+            this.consequenceExceptionHandler = (org.drools.runtime.rule.ConsequenceExceptionHandler) object;
+        }
     }
 
     public void setWorkingMemory(final InternalWorkingMemory workingMemory) {
@@ -232,7 +243,7 @@
         knowledgeHelper = (KnowledgeHelper) in.readObject();
         activeActivations = in.readInt();
         dormantActivations = in.readInt();
-        consequenceExceptionHandler = (ConsequenceExceptionHandler) in.readObject();
+        legacyConsequenceExceptionHandler = (ConsequenceExceptionHandler) in.readObject();
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
@@ -248,7 +259,7 @@
         out.writeObject( knowledgeHelper );
         out.writeInt( activeActivations );
         out.writeInt( dormantActivations );
-        out.writeObject( consequenceExceptionHandler );
+        out.writeObject( legacyConsequenceExceptionHandler );
     }
 
     /*
@@ -898,9 +909,17 @@
                                                             this.workingMemory );
             this.knowledgeHelper.reset();
         } catch ( final Exception e ) {
-            this.consequenceExceptionHandler.handleException( activation,
-                                                              this.workingMemory,
-                                                              e );
+            if ( this.legacyConsequenceExceptionHandler != null ) {
+                this.legacyConsequenceExceptionHandler.handleException( activation,
+                                                                        this.workingMemory,
+                                                                        e );
+            } else if ( this.consequenceExceptionHandler != null ) {
+                this.consequenceExceptionHandler.handleException( activation,
+                                                                  new StatefulKnowledgeSessionImpl( (ReteooStatefulSession) this.workingMemory ),
+                                                                  e );
+            } else {
+                throw new RuntimeException( e );
+            }
         }
 
         if ( activation.getRuleFlowGroupNode() != null ) {
@@ -1019,4 +1038,7 @@
         }
     }
 
+    public ConsequenceExceptionHandler getConsequenceExceptionHandler() {
+        return this.legacyConsequenceExceptionHandler;
+    }
 }

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/DefaultConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/DefaultConsequenceExceptionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/runtime/rule/impl/DefaultConsequenceExceptionHandler.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -0,0 +1,26 @@
+package org.drools.runtime.rule.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.runtime.rule.Activation;
+import org.drools.runtime.rule.ConsequenceExceptionHandler;
+import org.drools.runtime.rule.WorkingMemory;
+
+public class DefaultConsequenceExceptionHandler implements ConsequenceExceptionHandler, Externalizable {
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+    }
+
+    public void handleException(Activation activation,
+                                WorkingMemory workingMemory,
+                                Exception exception) {
+        throw new org.drools.runtime.rule.ConsequenceException( exception, activation.getRule() );
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/ConsequenceExceptionHandler.java	2008-11-07 01:36:23 UTC (rev 23767)
@@ -1,15 +1,15 @@
 package org.drools.spi;
 
-import java.io.Externalizable;
-
+import org.drools.spi.Activation;
 import org.drools.WorkingMemory;
 
+
 /**
  * Care should be taken when implementing this class. Swallowing of consequence can be dangerous
  * if the exception occured during a WorkingMemory action, thus leaving the integrity of the
  * WorkingMemory invalid.
  *
  */
-public interface ConsequenceExceptionHandler extends Externalizable {
+public interface ConsequenceExceptionHandler {
     void handleException(Activation activation, WorkingMemory workingMemory, Exception exception);
 }

Modified: labs/jbossrules/trunk/drools-core/src/main/resources/META-INF/drools.default.rulebase.conf
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/resources/META-INF/drools.default.rulebase.conf	2008-11-07 00:27:41 UTC (rev 23766)
+++ labs/jbossrules/trunk/drools-core/src/main/resources/META-INF/drools.default.rulebase.conf	2008-11-07 01:36:23 UTC (rev 23767)
@@ -15,7 +15,7 @@
 drools.logicalOverride = DISCARD
 drools.executorService = org.drools.concurrent.DefaultExecutorService
 drools.conflictResolver = org.drools.conflict.DepthConflictResolver
-drools.consequenceExceptionHandler = org.drools.base.DefaultConsequenceExceptionHandler
+drools.consequenceExceptionHandler = org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler
 drools.ruleBaseUpdateHandler = org.drools.base.FireAllRulesRuleBaseUpdateListener
 drools.workDefinitions = WorkDefinitions.conf
 drools.processInstanceManagerFactory = org.drools.process.instance.impl.DefaultProcessInstanceManagerFactory




More information about the jboss-svn-commits mailing list