[
http://jira.jboss.com/jira/browse/JBRULES-1403?page=comments#action_12409036 ]
Kris Verlaenen commented on JBRULES-1403:
-----------------------------------------
We discourage the use of control flow statements like if () in MVEL, especially inside
rule consequences (to force the user into making rules more declarative). You can override
this default by setting the MVEL language level (which is actually a static property in
MVEL) to 5 by changing the "drools.dialect.mvel.langLevel" configuration
property, for example by using a configuration file or by using this code to create your
PackageBuilder:
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
((MVELDialectConfiguration)
conf.getDialectConfiguration("mvel")).setLangLevel(5);
PackageBuilder builder = new PackageBuilder(conf);
...
You can also simply use the Java dialect, which supports all normal Java control flow
constructs.
Control-Flow Statement into "action nodes" (RULEFLOW)
-----------------------------------------------------
Key: JBRULES-1403
URL:
http://jira.jboss.com/jira/browse/JBRULES-1403
Project: JBoss Drools
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Components: Eclipse IDE
Affects Versions: 4.0.3
Environment: Eclipse Europa 3.3.1.1
Reporter: Massimiliano Magistri
Assigned To: Kris Verlaenen
Fix For: 5.0.0-M1
Attachments: action.jpg
I tried to add the following (stupid) statement into the action node "textual
editor":
if (true) int i=0;
and I got back an exception as follows:
org.mvel.PropertyAccessException: unable to resolve property: if ( true )
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:291)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:107)
at org.mvel.ASTNode.getReducedValueAccelerated(ASTNode.java:185)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:108)
at org.mvel.MVEL.executeExpression(MVEL.java:230)
at
org.drools.ruleflow.instance.impl.ActionNodeInstanceImpl.trigger(ActionNodeInstanceImpl.java:93)
at
org.drools.ruleflow.instance.impl.StartNodeInstanceImpl.triggerCompleted(StartNodeInstanceImpl.java:38)
at
org.drools.ruleflow.instance.impl.StartNodeInstanceImpl.trigger(StartNodeInstanceImpl.java:30)
at
org.drools.ruleflow.instance.impl.RuleFlowProcessInstanceImpl.start(RuleFlowProcessInstanceImpl.java:172)
at
org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1409)
at mytest.TestRF.testScritturaContractRF(TestRF.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NullPointerException
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:519)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:257)
... 29 more
Is it possible to add "flow control" statements into the action ruleflow nodes?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira