Interface dnx.util.DNXObservable
All Packages Class Hierarchy This Package Previous Next Index
Interface dnx.util.DNXObservable
- public interface DNXObservable
- extends Object
This class provides a lower-level and more flexible paradigm than
the standard Java Observable class paradigm.
In this paradigm, objects that want to be observed implement
the DNXObservable interface, and create a DNXObservableEngine as
necessary to handle the observation mechanism.
If you don't need the power of this paradigm and the simpler Java-style
paradigm is sufficient, you can also use DNXJavaStyleObservable,
which is implemented using this paradigm.
Here are some reasons for the different paradigm:
1) The most important reason is that in the standard Observable
class, the notifyObservers() method synchronizes around the
entire method call on the Observable. This tends to cause
deadlocks when multiple threads are sending and receiving
updates. There is basically no way to work around this using the
standard Observable class.
2) The standard Observable class inherits from Object, not DNXObject.
This is a problem because we want everything to inherit from
DNXObject, so we have standard assert() methods in every class.
Here once again we are screwed by the cursed lack of multiple
inheritance in Java.
3) The standard Observable class bogusly requires two method calls
to do the equivalent of our updateObservers(). Not only does this
require us to synchronize around the two calls to avoid race
conditions (which conflicts with #1), but one of the two methods
(setChanged()) is declared protected, making it impossible without
further kludgery for various classes to send updates on behalf
of another class's object.
4) Inheriting from an Observable class causes the object to always
take up extra space, rather than doing so only when necessary
(e.g. by allocating the DNXObservableEngine and storing it into
an "aux-data" structure, like for Node).
-
addObserver(DNXObserver)
-
-
addObserver(DNXObserver, int)
-
-
countObservers()
-
-
deleteObserver(DNXObserver)
-
-
deleteObservers()
-
-
getObservableEngine()
-
-
getObserverEventMask()
-
getObservableEngine
public abstract DNXObservableEngine getObservableEngine()
getObserverEventMask
public abstract int getObserverEventMask()
addObserver
public abstract void addObserver(DNXObserver o)
addObserver
public abstract void addObserver(DNXObserver o,
int mask)
countObservers
public abstract int countObservers()
deleteObserver
public abstract void deleteObserver(DNXObserver o)
deleteObservers
public abstract void deleteObservers()
All Packages Class Hierarchy This Package Previous Next Index