[jboss-jira] [JBoss JIRA] (DROOLS-2733) Support MVEL Dialect using custom inline accumulate code with external declarations in the executable model

Luca Molteni (JIRA) issues at jboss.org
Thu Jul 12 06:10:00 EDT 2018


     [ https://issues.jboss.org/browse/DROOLS-2733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luca Molteni updated DROOLS-2733:
---------------------------------
    Description: 
The executable model doesn't support custom inline accumulate code that uses external declarations such as

{code:java}
      String str = "import " + Person.class.getCanonicalName() + ";\n" +
                "rule R when\n" +
                "  String( $l : length )" +
                "  $sum : Integer() from accumulate (\n" +
                "            Person( age > 18, $age : age ), init( int sum = 0 * $l; ), action( sum += $age; ), reverse( sum -= $age; ), result( sum )\n" +
                "         )" +
                "then\n" +
                "  insert($sum);\n" +
                "end";
{code}

(Notice that in the init we multiply the sum value with the length of string)

But it can support such style using the "classic" generation of accumulate classes which gets compiled among the executable model and instantiate during the execution of the DSL.

This mechanism is broken with the MVEL dialect, as we don't have such generated classes.

Probably what we should do instead is putting MVEL expressions in the DSL directly such as 

{code:java}
accumulateScript("initCode", "accCode", "reverseCode");
{code}

and then during interpretation create a new MVEL context and execute the accumulate in memory

  was:
The executable model doesn't support custom inline accumulate code that uses external declarations such as

`      String str = "import " + Person.class.getCanonicalName() + ";\n" +
                "rule R when\n" +
                "  String( $l : length )" +
                "  $sum : Integer() from accumulate (\n" +
                "            Person( age > 18, $age : age ), init( int sum = 0 * $l; ), action( sum += $age; ), reverse( sum -= $age; ), result( sum )\n" +
                "         )" +
                "then\n" +
                "  insert($sum);\n" +
                "end";
`

(Notice that in the init we multiply the sum value with the length of string)

But it can support such style using the "classic" generation of accumulate classes which gets compiled among the executable model and instantiate during the execution of the DSL.

This mechanism is broken with the MVEL dialect, as we don't have such generated classes.

Probably what we should do instead is putting MVEL expressions in the DSL directly such as 

`accumulateScript("initCode", "accCode", "reverseCode");`

and then during interpretation create a new MVEL context and execute the accumulate in memory



> Support MVEL Dialect using custom inline accumulate code with external declarations in the executable model
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: DROOLS-2733
>                 URL: https://issues.jboss.org/browse/DROOLS-2733
>             Project: Drools
>          Issue Type: Feature Request
>            Reporter: Luca Molteni
>            Assignee: Luca Molteni
>            Priority: Optional
>
> The executable model doesn't support custom inline accumulate code that uses external declarations such as
> {code:java}
>       String str = "import " + Person.class.getCanonicalName() + ";\n" +
>                 "rule R when\n" +
>                 "  String( $l : length )" +
>                 "  $sum : Integer() from accumulate (\n" +
>                 "            Person( age > 18, $age : age ), init( int sum = 0 * $l; ), action( sum += $age; ), reverse( sum -= $age; ), result( sum )\n" +
>                 "         )" +
>                 "then\n" +
>                 "  insert($sum);\n" +
>                 "end";
> {code}
> (Notice that in the init we multiply the sum value with the length of string)
> But it can support such style using the "classic" generation of accumulate classes which gets compiled among the executable model and instantiate during the execution of the DSL.
> This mechanism is broken with the MVEL dialect, as we don't have such generated classes.
> Probably what we should do instead is putting MVEL expressions in the DSL directly such as 
> {code:java}
> accumulateScript("initCode", "accCode", "reverseCode");
> {code}
> and then during interpretation create a new MVEL context and execute the accumulate in memory



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list