I'm afraid I don't understand what the issue is. You register a listener, you set the event mask, and you make note of all the events that interest you. This should be perfect for you.

On Jan 16, 2008, at 1:09 PM, Nice Bright wrote:

Hi everybody,
  I have tried the listener solution, but it does not work for me.
  Actually what I want to achieve is:

  1-assert a fact
  2-running Jess by Rete .run( )
3-get the list of fired rules and asserted facts resulted by the above tasks

  I tested the following code. what I undrestand is :

First event: asserting a fact is an event, which may cause one(or more) rule be activated . activation contains the record of rule and related fact ( will be fired next)

Second Event: running Rete.run( ) is another event which cause to fire the rules. although the type of this event is jessEvent.FACT which just notify that a fact has been asserted or retracted.

  So in this way I could not access to hte list of fired rules.

  Could you please guide me .
  Thanks,
  Nice



  I have tried the following code to test what je contains,

  class MyEventHandler implements JessListener{

      public void eventHappened(JessEvent je) {

          if (je.getType()== JessEvent.DEFRULE_FIRED ){
System.out.println("Rule Fired"+ ((Activation) je.getObject()).getRule().getName()+" That's the rule ");

                            Fact f=je.getContext().getFact();
System.out.println("fact name is :"+f.getName());
        }//eof if
   else

   if(je.getType()== 16 ){// or DEFFact
                            System.out.println("It is a DefFact");

                           // Fact f=je.getContext().getFact();
                           // f.toStringWithParens();
                          //  int FactID=f.getFactId();

        }//eof if
}//eof eventHappened
  }//eof class

Ernest Friedman-Hill <[EMAIL PROTECTED]> wrote:

On Jan 9, 2008, at 7:40 AM, Nice Bright wrote:



How can I get all the results after running a rete engine? In the
other words, I want to get all the fires rules after the running of
engine into an iterator (if there is any fired rules ). In the
following code after running engine, if the number of fired rules
is greater than 0, I am looking for a method call in rete class
that helps me to get the list of fired rules.



There's no way to get the (potentially infinite) list of fired rules
after they've fired, because Jess doesn't store this kind of history
information; but you can get Jess to tell you about each rule as it
fires, so you can save the history information yourself. Use the
"JessListener" facility with an event type of
JessEvent.DEFRULE_FIRED, and your listener will be notified each time
a rule fires. You could then save whatever information you want out
of each event into a List. See http://herzberg.ca.sandia.gov/jess/
docs/70/library.html#events for info on JessListeners.

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify owner-jess- [EMAIL PROTECTED]

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550                 http://www.jessrules.com

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to