[jboss-svn-commits] JBL Code SVN: r16854 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Nov 27 06:34:24 EST 2007


Author: mark.proctor at jboss.com
Date: 2007-11-27 06:34:23 -0500 (Tue, 27 Nov 2007)
New Revision: 16854

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java
Log:
JBRULES-1197 Extends actions support to include other dialects and callback
-added first end to end test for dialectable actions

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java	2007-11-27 08:14:51 UTC (rev 16853)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/instance/impl/ActionNodeInstanceImpl.java	2007-11-27 11:34:23 UTC (rev 16854)
@@ -49,53 +49,60 @@
     }
 
     public void internalTrigger(final RuleFlowNodeInstance from) {
-		Object action = getActionNode().getAction();
-		if (action instanceof DroolsConsequenceAction) {
-			String actionString = ((DroolsConsequenceAction) action).getConsequence();
-    		ExpressionCompiler compiler = new ExpressionCompiler(actionString);
-    		ParserContext parserContext = new ParserContext();
-    		// imports
-    		List imports = getProcessInstance().getRuleFlowProcess().getImports();
-    		Set importSet = new HashSet();
-    		if (imports != null) {
-        		importSet.addAll(imports);
-    			for (Iterator iterator = imports.iterator(); iterator.hasNext(); ) {
-    				String importClassName = (String) iterator.next();
-    				if ( importClassName.endsWith( ".*" ) ) {
-    					importClassName = importClassName.substring(0, importClassName.indexOf(".*"));
-    		            parserContext.addPackageImport(importClassName);
-    		        } else {
-	    				try {
-	    					parserContext.addImport(Class.forName(importClassName));
-	    				} catch (ClassNotFoundException e) {
-	    					// class not found, do nothing
-	    				}
-    		        }
-    			}
-    		}
-    		TypeResolver typeResolver = new ClassTypeResolver(importSet, Thread.currentThread().getContextClassLoader());
-    		// compile expression
-    		Serializable expression = compiler.compile(parserContext);
-    		// globals
-    		Map globalDefs = getProcessInstance().getRuleFlowProcess().getGlobals();
-    		Map globals = new HashMap();
-    		if (globalDefs != null) {
-    			for (Iterator iterator = globalDefs.entrySet().iterator(); iterator.hasNext(); ) {
-    				Map.Entry entry = (Map.Entry) iterator.next();
-    				try {
-    					globals.put(entry.getKey(), typeResolver.resolveType((String) entry.getValue()));
-    				} catch (ClassNotFoundException exc) {
-    					throw new IllegalArgumentException("Could not find type " + entry.getValue() + " of global " + entry.getKey());
-    				}
-    			}
-    		}
-    		// execute
-    		DroolsMVELFactory factory = new DroolsMVELFactory(Collections.EMPTY_MAP, null, globals);
-    		factory.setContext(null, null, null, getProcessInstance().getWorkingMemory(), null);
-    		MVEL.executeExpression(expression, null, factory);
-		} else {
-			throw new RuntimeException("Unknown action: " + action);
+		Action action = (Action) getActionNode().getAction();
+		
+		try {
+	        action.execute( getProcessInstance().getWorkingMemory() );		    
+		} catch (Exception e) {
+		    throw  new RuntimeException("unable to execute Action", e);
 		}
+		
+//		if (action instanceof DroolsConsequenceAction) {
+//			String actionString = ((DroolsConsequenceAction) action).getConsequence();
+//    		ExpressionCompiler compiler = new ExpressionCompiler(actionString);
+//    		ParserContext parserContext = new ParserContext();
+//    		// imports
+//    		List imports = getProcessInstance().getRuleFlowProcess().getImports();
+//    		Set importSet = new HashSet();
+//    		if (imports != null) {
+//        		importSet.addAll(imports);
+//    			for (Iterator iterator = imports.iterator(); iterator.hasNext(); ) {
+//    				String importClassName = (String) iterator.next();
+//    				if ( importClassName.endsWith( ".*" ) ) {
+//    					importClassName = importClassName.substring(0, importClassName.indexOf(".*"));
+//    		            parserContext.addPackageImport(importClassName);
+//    		        } else {
+//	    				try {
+//	    					parserContext.addImport(Class.forName(importClassName));
+//	    				} catch (ClassNotFoundException e) {
+//	    					// class not found, do nothing
+//	    				}
+//    		        }
+//    			}
+//    		}
+//    		TypeResolver typeResolver = new ClassTypeResolver(importSet, Thread.currentThread().getContextClassLoader());
+//    		// compile expression
+//    		Serializable expression = compiler.compile(parserContext);
+//    		// globals
+//    		Map globalDefs = getProcessInstance().getRuleFlowProcess().getGlobals();
+//    		Map globals = new HashMap();
+//    		if (globalDefs != null) {
+//    			for (Iterator iterator = globalDefs.entrySet().iterator(); iterator.hasNext(); ) {
+//    				Map.Entry entry = (Map.Entry) iterator.next();
+//    				try {
+//    					globals.put(entry.getKey(), typeResolver.resolveType((String) entry.getValue()));
+//    				} catch (ClassNotFoundException exc) {
+//    					throw new IllegalArgumentException("Could not find type " + entry.getValue() + " of global " + entry.getKey());
+//    				}
+//    			}
+//    		}
+//    		// execute
+//    		DroolsMVELFactory factory = new DroolsMVELFactory(Collections.EMPTY_MAP, null, globals);
+//    		factory.setContext(null, null, null, getProcessInstance().getWorkingMemory(), null);
+//    		MVEL.executeExpression(expression, null, factory);
+//		} else {
+//			throw new RuntimeException("Unknown action: " + action);
+//		}
     	triggerCompleted();
     }
 




More information about the jboss-svn-commits mailing list