Karthizap,
The only thing I could think of for you is to use a function in the DRL
to store your "name" value, but any solution where you change your DRL will
require you to redeploy the DRL file (obviously).
Since your "name" changes quite often, can't you make it a fact of your
reasoning process? Just to keep with the "Person" theme, make a helper class
called AssignedName or something like that and do:
when
AssignedName( $an : name )
Person( name == $an )
then
end
This will even prevent re-deployments of the DRL itself. Also, a join
like the above has cost O(1), so extremely good perf also (better than a
function call).
Drools does not support constants declaration in the DRL file, as you
know, but maybe this is something we could add. Do you want to open a JIRA
with a feature request for that? (That would still require DRL redeployment
discussed above, obviously).
Edson
2009/6/1 karthizap <karthizap(a)gmail.com>
Thanks for your reply Earnie. In the following example, don't want to
hardcode Person Name value like "John" in the DRL file. I want to refer it
from some other sources(If i refer it from java class file, name value is
getting changed quiet often, have to recompile the java source and deploy).
My main requirement is, if the name value is getting changed, don't want to
redeploy/restart the application. i would like to do the changes in the drl
file only without hard coding.
rule "Test Rule"
when
$person : Person( name == "John")
then
$person.setActivation(true)
end
Karthikeyan
Please explain, how i can refer global object in LHS?
Earnie D wrote:
>
> How about adding them as Globals and referencing them that way? You
should
> be able to put them in a map as well in a Global and reference them.
>
> Earnie!
>
>
>
>
> ________________________________
> From: karthizap <karthizap(a)gmail.com>
> To: rules-users(a)lists.jboss.org
> Sent: Monday, June 1, 2009 7:14:56 AM
> Subject: re[rules-users] move hardcoded values in DRL or have constants
> inside drl
>
> Is there is anyway i can remove hardcoded values in the DRL file? Can I
> have the constants file(like data dictionary) inside drl/functions. I
> don't want to refer java constants class directly in drl file and would
> like to declare and refer those constants inside drl file.
> ________________________________
> View this message in context: remove hardcoded values in DRL or have
> constants inside drl
> Sent from the drools - user mailing list archive at
Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context:
http://www.nabble.com/remove-hardcoded-values-in-DRL-or-have-constants-in...
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @
www.jboss.com