[jboss-svn-commits] JBL Code SVN: r24376 - labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Dec 14 23:45:46 EST 2008


Author: michael.neale at jboss.com
Date: 2008-12-14 23:45:46 -0500 (Sun, 14 Dec 2008)
New Revision: 24376

Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java
Log:
auto rebuild on scenario run fail


Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java	2008-12-15 03:26:43 UTC (rev 24375)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java	2008-12-15 04:45:46 UTC (rev 24376)
@@ -1777,22 +1777,41 @@
     private RuleBase loadRuleBase(PackageItem item,
                                   ClassLoader cl) throws DetailedSerializableException {
         try {
-            RuleBase rb = RuleBaseFactory.newRuleBase( new RuleBaseConfiguration( cl ) );
-            Package bin = (Package) DroolsStreamUtils.streamIn( item.getCompiledPackageBytes(),
-                                                                cl );
-            rb.addPackage( bin );
-            return rb;
+            return deserKnowledgebase(item, cl);
         } catch ( ClassNotFoundException e ) {
             log.error( e );
             throw new DetailedSerializableException( "A required class was not found.",
                                                      e.getMessage() );
         } catch ( Exception e ) {
             log.error( e );
-            throw new DetailedSerializableException( "Unable to load a rulebase.",
-                                                     e.getMessage() );
+            log.info("...but trying to rebuild binaries...");
+            try {
+                BuilderResult[] res = this.buildPackage(
+                                                         "",
+                                                         true , item);
+                if (res != null && res.length > 0) {
+                    throw new DetailedSerializableException("There were errors when rebuilding the knowledgebase.", "");
+                }
+                try {
+                    return deserKnowledgebase(item, cl);
+                } catch (Exception e2) {
+                    throw new DetailedSerializableException("Unable to reload knowledgebase.", e.getMessage());
+                }
+            } catch (SerializableException e1) {
+                throw new DetailedSerializableException("Unable to rebuild the rulebase.", "");
+            }
+
         }
     }
 
+    private RuleBase deserKnowledgebase(PackageItem item, ClassLoader cl) throws IOException, ClassNotFoundException {
+        RuleBase rb = RuleBaseFactory.newRuleBase( new RuleBaseConfiguration( cl ) );
+        Package bin = (Package) DroolsStreamUtils.streamIn( item.getCompiledPackageBytes(),
+                                                            cl );
+        rb.addPackage( bin );
+        return rb;
+    }
+
     private SingleScenarioResult runScenario(Scenario scenario,
                                              PackageItem item,
                                              ClassLoader cl,




More information about the jboss-svn-commits mailing list