Package net.sf.okapi.common.observer
Class WeakReferenceObservable
- java.lang.Object
-
- net.sf.okapi.common.observer.BaseObservable
-
- net.sf.okapi.common.observer.WeakReferenceObservable
-
- All Implemented Interfaces:
IObservable
public class WeakReferenceObservable extends BaseObservable
Implementation ofIObservablethat holds references to Observers as WeakReferences. This implementation notifies the observers in a synchronous fashion. Note that this can cause trouble if you notify the observers while in a transactional context because the notification is then done also in the transaction.This class is based on the work done by Martin Fischer. See references below.
- Author:
- Martin Fischer (original author), Richard Gomes, Srinivas Hasti
- See Also:
-
Martin Fischer: Observer and Observable interfaces,
Improved Observer/Observable,
IObservable,IObserver,BaseObservable
-
-
Constructor Summary
Constructors Constructor Description WeakReferenceObservable(IObservable observable)Creates a new WeakReferenceObservable object with a givenIObservableobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObserver(IObserver observer)Attaches a observer to the Observable.voiddeleteObserver(IObserver observer)Detaches a previously attached observer to the observable.-
Methods inherited from class net.sf.okapi.common.observer.BaseObservable
countObservers, deleteObservers, getObservers, notifyObservers, notifyObservers, wrappedNotify
-
-
-
-
Constructor Detail
-
WeakReferenceObservable
public WeakReferenceObservable(IObservable observable)
Creates a new WeakReferenceObservable object with a givenIObservableobject.- Parameters:
observable- the object to observe.
-
-
Method Detail
-
addObserver
public void addObserver(IObserver observer)
Description copied from interface:IObservableAttaches a observer to the Observable. After attachment the observer gets informed about changes in the Observable.- Specified by:
addObserverin interfaceIObservable- Overrides:
addObserverin classBaseObservable- Parameters:
observer- The observer to attach to the observable
-
deleteObserver
public void deleteObserver(IObserver observer)
Description copied from interface:IObservableDetaches a previously attached observer to the observable. After detachment the observer does no longer receive change notifications from the observable.- Specified by:
deleteObserverin interfaceIObservable- Overrides:
deleteObserverin classBaseObservable- Parameters:
observer- The observer to detach from the observable
-
-