<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
SPAAARKY21 wrote:
<blockquote cite="mid:25855520.post@talk.nabble.com" type="cite">
  <pre wrap="">I'm basically writing a debugging tool that allows developers to step through
the rule engine itself.  In a sense, I'm mimicking the way Jess' developers
rely on the (all-agenda) and (run 1) functions, but in a graphic way as
opposed to command line functions.

Inside of afterActivationFired(), I am displaying information like a current
view of the agenda, and then waiting for user input before returning control
to the rule engine.  Tracking the activations myself is a good idea.  I'm
just disappointed that the Drools' API no longer provides the methods needed
to inspect the focus stack and its activations.  It used to.  I suppose I
could always cast the Agenda I get to its concrete implementation but I
would rather not.

Anyway, thanks again for the help.
  </pre>
</blockquote>
We purposefuly limit what we expose to end users, as otherwise it
becomes a can of worms and you get leaky exposures, which is what
happened in drools 3 and 4. Casting isn't a problem, just be prepared
that internal apis can change.<br>
<br>
Mark<br>
<blockquote cite="mid:25855520.post@talk.nabble.com" type="cite">
  <pre wrap="">

Pegram, Macon wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Using the listener, you could construct your own agenda stack to track
what's going on.  The AgendaEventListener interface has the methods:
    agendaGroupPopped(AgendaGroupPoppedEvent event) 
    agendaGroupPushed(AgendaGroupPushedEvent event)
    
In your listener, construct a java.util.Stack, and just Push/Pop
agenda-group information that you retrieve from the AgendaGroupXXXEvent
onto/off of your internal Stack.  You can do similar tracking of event
firing with the "before" or "after" ActivationFired event.  Construct a
list to capture the sequence of events.  

I'm not entirely clear on what you're trying to accomplish, but the
event listener interface provides hook points for all the related events
on the agenda, so you should be able to craft a listener to do whatever
you need.  I've used a similar mechanism in unit testing to validate
correct processing of a set of agenda groups.  

Macon

-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
[<a class="moz-txt-link-freetext" href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>] On Behalf Of SPAAARKY21
Sent: Sunday, October 11, 2009 7:34 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
Subject: Re: [rules-users] Drool 5 API and Agenda Listeners


Thanks for clearing that up for me.

As for the agenda, I am writing an agenda listener already but the
problem
is getting the information I want.  In Drools 5, an
org.drools.event.rule.AgendaEventListener's afterActivationFired()
method
takes an org.drools.event.rule.AfterActivationFiredEvent object but
where do
I go from there?  The getKnowledgeRuntime() method returns a
KnowledgeRuntime, which has a getAgenda() method that returns an
org.drools.runtime.rule.Agenda.  But that Agenda doesn't have methods
for
getting all of the agenda groups on the focus stack.  It only has
methods to
clear the agenda or get an activation/agenda/rule flow group by name.
What
I am looking for is a way to get all of the agenda groups on the focus
stack
(as a List or through an Iterator,) and then get each activation from
each
one of those groups.

In Drools 4, I would have been using an org.drools.Agenda instead, which
has
a getAgendaGroups() method and AgendaGroup has a getActivations()
method. 
In a Drools 5 org.drools.runtime.rule.AgendaGroup, there are only three
methods - clear(), getName() and setFocus() - so even if I could get all
of
the AgendaGroups, it wouldn't do me any good.  Do you see why I'm having
trouble doing anything useful with the new API?  In Drool 5, are you
supposed to approach this in a different way (not in an agenda
listener?)


Pegram, Macon wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">The primary reason to move to the "Knowledge APIs" apart from what
you've already mentioned is that they help to bring together the
      </pre>
    </blockquote>
    <pre wrap="">newest
    </pre>
    <blockquote type="cite">
      <pre wrap="">features of Drools.  In a single KnowledgeBase you can now have not
      </pre>
    </blockquote>
    <pre wrap="">only
    </pre>
    <blockquote type="cite">
      <pre wrap="">rules, but Flows, and Complex Event Processing.   

As to tracking activity on the agenda... there's two ways...
1. If you're using Eclipse, one great feature of the Drools plugin is
the Audit Log.  You can start logging with the following code:
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(knowledgeSession,
      </pre>
    </blockquote>
    <pre wrap="">FILENAME);
    </pre>
    <blockquote type="cite">
      <pre wrap="">Then open the resulting log in the Eclipse Drools Audit Log tab and
      </pre>
    </blockquote>
    <pre wrap="">get
    </pre>
    <blockquote type="cite">
      <pre wrap="">a pretty good graphical representation of what happened during your
      </pre>
    </blockquote>
    <pre wrap="">run.
    </pre>
    <blockquote type="cite">
      <pre wrap="">See the following URL for a screenshot:

      </pre>
    </blockquote>
    <pre wrap=""><a class="moz-txt-link-freetext" href="http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/h">http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/h</a>
    </pre>
    <blockquote type="cite">
      <pre wrap="">tml_single/index.html#d0e6801

2. Create your own AgendaEventListener.   Simply implement the
      </pre>
    </blockquote>
    <pre wrap="">interface
    </pre>
    <blockquote type="cite">
      <pre wrap="">and place whatever actions you want on each event.  Then attach it to
your session before you start processing like this:
knowledgeSession.addEventListener(new YourAgendaListener());

Macon

-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
[<a class="moz-txt-link-freetext" href="mailto:rules-users-bounces@lists.jboss.org">mailto:rules-users-bounces@lists.jboss.org</a>] On Behalf Of SPAAARKY21
Sent: Sunday, October 11, 2009 12:26 PM
To: <a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
Subject: [rules-users] Drool 5 API and Agenda Listeners


I recently moved from Drool 4 to 5 in a little example application I
      </pre>
    </blockquote>
    <pre wrap="">had
    </pre>
    <blockquote type="cite">
      <pre wrap="">written.  At first I hesitated because I thought the API had changed
drastically. When I did upgrade, I found that there were few changes. 
However, I was still using all of the "Rule" classes instead of the
"Knowledge" classes - like RuleBase and StatefulRuleSession instead of
KnowledgeBase and StatefulKnowledgeBase.  It sounds like the
      </pre>
    </blockquote>
    <pre wrap="">"Knowledge"
    </pre>
    <blockquote type="cite">
      <pre wrap="">API
is the way of the future so to speak but I haven't been able to find
much
information on it.  What is the advantage in using the new "Knowledge"
API? 
Will the "Rule" API become deprecated at some point?

Anyway, after switching to the Knowledge API, I have been working on
      </pre>
    </blockquote>
    <pre wrap="">an
    </pre>
    <blockquote type="cite">
      <pre wrap="">agenda listener I had written.  What I want to do is iterate through
agenda
groups on the focus stack and, for each group, iterate through the
activations in the order in which they are queued up.  However, I
      </pre>
    </blockquote>
    <pre wrap="">don't
    </pre>
    <blockquote type="cite">
      <pre wrap="">see
any way to do that.  In fact, since switching to Drools 5 and the
"Knowledge" API, it looks like the API for dealing with the agenda and
activations and whatnot has become quite small.  Or at least it is
      </pre>
    </blockquote>
    <pre wrap="">when
    </pre>
    <blockquote type="cite">
      <pre wrap="">you
stick to the interfaces.  Am I missing a better way of doing this?

Brandon
-- 
View this message in context:

      </pre>
    </blockquote>
    <pre wrap=""><a class="moz-txt-link-freetext" href="http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258449">http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258449</a>
    </pre>
    <blockquote type="cite">
      <pre wrap="">04.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>

_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>


      </pre>
    </blockquote>
    <pre wrap="">-- 
View this message in context:
<a class="moz-txt-link-freetext" href="http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258488">http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258488</a>
53.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>

_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>


    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
<br>
</body>
</html>