I just extended Rete to make the example simpler. I also tried it with
an independent JessListener implementing class, but the problem is the same.
I tried to do Rete.addJessListener() after bload, just as you suggested,
but the problem remains.
So, I ask again: what could be wrong in my bsaved file that prevents
some JessEvents from being notified?
Henrique
Jonathan Sewall wrote:
> I didn't extend Rete just to create a JessListener, but I did find
> that I needed to reregister my listeners after bload.
> Henrique Lopes Cardoso wrote:
>> I am stumbling for some time now with the use of a JessListener. After
>> many tries, I figured out that the listener does not work properly when
>> I bload() certain files.
>>
>> Since the Rete class implements JessListener, for ease of testing I
>> extended it and got to the class below.
>> From my experiences, if the bsave file is empty, it works fine. If I use
>> another bsaved file that I have, I get problems. Only the retracted
>> facts are being notified.
>>
>> Is this a bug? What should I look for in my bsaved file?
>>
>> Thanks.
>>
>> Henrique
>>
>> //---------------------------------------------
>> public class JEL extends Rete {
>> public JEL() {
>> super();
>> // set event mask
>> setEventMask(JessEvent.FACT);
>> // load file
>> try {
>> FileInputStream fis = new FileInputStream("somefile.bsave");
>> bload(fis);
>> fis.close();
>> } catch (ClassNotFoundException cnfe) {
>> cnfe.printStackTrace();
>> } catch (IOException ioe) {
>> ioe.printStackTrace();
>> }
>> }
>> public void eventHappened(JessEvent jev) {
>> System.out.println("EVENT:" +
>> JessEvent.getEventName(jev.getType()));
>> switch(jev.getType()) {
>> case JessEvent.FACT | JessEvent.REMOVED: // retraction
>> Fact whatWasRetracted = (Fact) jev.getObject();
>> System.out.println("- - -" + whatWasRetracted);
>> break;
>> case JessEvent.FACT: // assertion
>> Fact whatWasAsserted = (Fact) jev.getObject();
>> System.out.println("+ + +" + whatWasAsserted);
>> break;
>> }
>> }
>> public static void main(String args[]) {
>> JEL jel = new JEL();
>> try {
>> jel.assertString("(qwe)");
>> jel.retractString("(qwe)");
>> jel.assertString("(asd)");
>> } catch(JessException je) {
>> je.printStackTrace();
>> }
>> }
>> }
>> //----------------------------------------------
>>
>>
>>
>> --------------------------------------------------------------------
>> 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]
>> --------------------------------------------------------------------
>>
>>
>>
>
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------
>
>
--
----- - - - - - - - - - - - -
Henrique Lopes Cardoso
DEEC/FEUP
Rua Dr. Roberto Frias | 4200-465 Porto
PORTUGAL
(+351)225081400 ext.1315
[EMAIL PROTECTED] | www.fe.up.pt/~hlc
----- - - - - - - - - - - - -
--------------------------------------------------------------------
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]
--------------------------------------------------------------------