James,
About globals, the concept is the same as the drools 2.x "Application
Data", but in 3.0 it is called global:
hi James,
i believe *event.getActivation().getTuple().getFactHandles()* should do...
holla
------------------------------------------------------------------------
*From:* rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] *On Behalf Of *James Depaul
*Sent:* Friday, February 09, 2007 3:59 AM
*To:* Rules Users List
*Subject:* Re: [rules-users] How to inovke a Service...
Thanks Edson -
Two questions:
1) Is using Globals (as you mention below) same as using
WorkingMemory.setApplicationData(myService) - or is this yet another
way to do it. Is there a difference in terms of efficiency?
2) Is there a way to get to the Fact that fired the event from the
Event object passed in the
AgendaEventListener.afterActivationFired(Event event)
>From an efficiency and performance standpoint, which way would you
recommend pursuing: EventListener invoking a service or service
invoked from global Helper class in current WorkingMemory? Any
guidance there would be appreciated.
Thanks,
James
Inactive hide details for Edson Tirelli <tirelli(a)post.com>Edson
Tirelli <tirelli(a)post.com>
*Edson Tirelli <tirelli(a)post.com>*
Sent by: rules-users-bounces(a)lists.jboss.org
02/08/2007 02:31 PM
Please respond to
Rules Users List <rules-users(a)lists.jboss.org>
To
Rules Users List <rules-users(a)lists.jboss.org>
cc
Subject
Re: [rules-users] How to inovke a Service...
James,
The consequence and function blocks in a DRL file are transformed
into a plain java method. It means you can do whatever you want and java
allows. So, if you are for instance inside an application server, you
cat get your JNDI context from there and do your stuff. Although, it is
usually better to have helper classes doing procedural code and keep the
consequence code clean to make rules maintance easier.
So, for exaple, you can have a helper class that has the actual code
to call the service you want and set it as a global for your rulebase.
Then in the consequence you call this class method with the given
paramenters.
Example:
package my.package;
global my.service.package.ServiceInvoker invoker;
rule "Cheese in stock"
when
$p : Person( $likes : likes )
$c : Cheese( type == $likes, quantity > 0 )
then
invoker.sendMessageToPerson( $p, "Your prefered cheese
("+$c.getType()+") is back in stock;" );
end
Inside your ServiceInvoker class you create the code to actually send
the message (procedural code).
This is only one way of doing it, but it is usually what is done.
Hope it helps.
[]s
Edson
jdepaul wrote:
>I've done a little research since my first post and have been
experimenting
>with the AgendaEventListener interface... I can register a component in
>WorkingMemory that will 'listen' and be notified afterEventFired event -
>this could be a good place from which to invoke my serivce, however, the
>problem I'm having is that the event delivered doesn't seem to pass the
>original Fact that caused the Event to fire, only the rule that got
>activated is sent... How could I get the Fact that caused this event to
>fire from that event object?
>
>James
>
>
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @
www.jboss.com
_______________________________________________
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
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @