public abstract class AbstractNotifyListener extends Object implements InvalidationListener
WeakListener wrapper.
Without this class, an observer which uses weak listeners would need to hold
two references. The first to the original ChangeListener to prevent
it from being garbage collected. The second to the WeakListener
wrapper so it can unregister once registered listener. The second reference
is eliminated by using this class.
Example:
public class Observer {
private AbstractNotifyListener listener = new AbstractNotifyListener() {
public void handle(Bean bean, PropertyReference property) {
// do something
}
};
public void start() {
subject.addChangeListener(property, listener.getWeakListener());
}
public void stop() {
subject.removeChangeListener(property, listener.getWeakListener());
}
}
| Constructor and Description |
|---|
AbstractNotifyListener() |
| Modifier and Type | Method and Description |
|---|---|
InvalidationListener |
getWeakListener() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinvalidatedpublic InvalidationListener getWeakListener()
Copyright © 2025. All rights reserved.