If you are using MVEL in rules, you must declare it, wherever it is used, in
each rule.
-W
2009/10/14 Chris Richmond <crichmond(a)referentia.com>
Great…..
So, can I simply switch the dialect to not use MVEL?
Chris
------------------------------
*From:* rules-users-bounces(a)lists.jboss.org [mailto:
rules-users-bounces(a)lists.jboss.org] *On Behalf Of *Wolfgang Laun
*Sent:* Wednesday, October 14, 2009 8:50 AM
*To:* Rules Users List
*Subject:* Re: [rules-users] setting globals in rule file
I've used functions with Drools 5, but not with MVEL. A recent thread
seemed to indicate a problem with MVEL for functions, though.
What you show of your code appears to be OK.
-W
On Wed, Oct 14, 2009 at 8:35 PM, Chris Richmond <crichmond(a)referentia.com>
wrote:
Yeah..more fun with functions. I have the following function
function String getMyValue(){ return "value 1"; }
I have declared it at the top of the rule file right after all imports and
dialect statement but before any rules
<imports>
global Services services;
global String currentProfilie;
# setup dialect for the semantic code to be MVEL
dialect "mvel"
function String getMyValue(){ return "value 1"; }
I then try to call the function from another rule consequence as a test:
then
System.err.println(getMapRouterAddress());
<other statements which work fine>
Now as soon as I start up and the rule file is loaded, I get a null pointer
exception that isn't really helpful as it simpoly points to one of my own
external objects that references the session that failed to load.
I have tried using functions many times and never successfully done so.
How/where do I place a simple function like this and call it?
Thanks
Chris
________________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Wednesday, October 14, 2009 8:15 AM
To: Rules Users List
Subject: Re: [rules-users] setting globals in rule file
You could let the "user" write some functions such as
function String parFoo(){ return "foo42"; }
and evaluate them in a rule firing with high priority on eval(true).
-W
2009/10/14 Chris Richmond <crichmond(a)referentia.com>
Hmm…
Well..I have this rule file and it seems like a darn convenient place to
set
some configuration settings so the user could change them in the plain text
file. Otherwise I have to implement another configuration settgin system
then feed that to th setGlobal…
Chris
________________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Wednesday, October 14, 2009 7:50 AM
To: Rules Users List
Subject: Re: [rules-users] setting globals in rule file
No, globals can only be set by calling the WorkingMemory method
wm.setGlobal(String name, Object value)
You could call this in a consequence (RHS), but it's usually not a good
idea
to do so.
What do you want to achieve?
-W
2009/10/14 Chris Richmond <crichmond(a)referentia.com>
Shouldn’t it be possible to set a global variable value within the rule
file
itself at the top. Something like?
global String deviceName = “myDevice”;
I thought you could do that, but consistently get an error saying illegal
character ‘=’ expected “(“
Or something along those lines.
This is possible and that syntax should work, shouldn’t it?
Thanks,
Chris
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users