You don't show us your DerivedTank and DerivedPump classes, but here's
a hypothesis: you commented out the implementations of the attributes,
but left in the PropertyChangeSupport-related code, so that there are
two m_pcs members: one each in the parent and child class. Then when
Jess registers itself as a listener, it is filed away by the child
class's methods in the child class's member variable; but when the
attribute code in the parent tries to fire a property change event, it
does so using the parent's PropertyChangeSUpport object, which has
never heard of Jess -- i.e., no-one 's listening to the events that
are actually being sent. Copying all the attribute code the the child
would fix this, as the child attributes would use the child
member. But the "right" way to fix it is to delete the property change
support stuff from the child.
"Shadowing" variables by redeclaring them in a child class is a Bad
Thing, and always leads to pain and sorrow, as in the present
case. Making it altogether illegal would be on my list of Things to
Change about Java.
I think rhalsey007 wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi All,
>
> I am in the process of "re-learning" Jess (after 3-4 years).
>
> At this time, I am examining (and modifying) the "pumps" example
> for the purpose of learning how JESS deals with class hierarchies and the
> associated polymorphism on method calls:
>
> (1) I have derived classes (DerivedPump / DerivedTank) from
> the existing Pump / Tank classes. The only real
> changes made were to the base classes were to comment out
> the Thread(this).start() line in both the Tank.java and
> Pump.java while in the derived classes I commented out
> the attributes, called the super class in the constructor,
> and added a new Thread(this).start() line. In addition,
> I commented out all method calls thinking that the
> "listener" interface call would make the call to the
> right method (polymorphically).
>
> (2) I am using the pumps.clp and modified the bottom part of
> the file to include:
>
> (definstance tank (bind ?tank (new DerivedTank "MAIN")))
> (call (?frame getContentPane) add (?tank getComponent))
> (definstance pump (bind ?pump (new DerivedPump "MAIN" ?tank)))
> (call (?frame getContentPane) add (?pump getComponent))
> (call (?frame getContentPane) add (new JLabel "MAIN"))
> (definstance tank (bind ?tank (new DerivedTank "AUX")))
> (call (?frame getContentPane) add (?tank getComponent))
> (definstance pump (bind ?pump (new DerivedPump "AUX" ?tank)))
>
> while leaving the top of the file alone, i.e.,
>
> (defclass tank Tank extends machine)
> (defclass pump Pump extends machine)
>
> (3) The MainInJava.java was modified to include:
>
> //Tank t = new Tank("MAIN");
> DerivedTank t = new DerivedTank("MAIN");
> //Pump p = new Pump("MAIN", t);
> DerivedPump p = new DerivedPump("MAIN", t);
>
> My fundamental assumption was that this code would run as is. It didn't.
> Only when I changed the derived classes to include ALL the methods from
> base class would it work. Small combinations of changes led it running
> in some cases and in some cases it wouldn't work. ONLY when ALL methods
> were included would it work correctly.
>
> Obviously, my assumptions were wrong !!
>
> However, my suspicion is that the "call-backs" from the "source" to
> the "eventListener" will go ONLY to the level of the class hierarchy that
> was registered for that particular event.
>
> This may be trivial for a JavaBean jock, but at this time, it is a
> complete mystery to me as to why it works this way.
>
> OBTW, I do have the modified "pumps" code working as advertised - I just
> don't understand the nuances.
>
> Thanks -
>
> Rich Halsey
>
>
>
>
>
>
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
--------------------------------------------------------------------
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]
--------------------------------------------------------------------