import java.util.Map;
import java.util.TreeMap;
-
/**
* Implements subscription and notification logic for an observer pattern. This
* class is thread safe.
/**
* Constructs the observable.
- *
+ *
* @param aObservable
* Observable this instance is used for.
* @param aNotifier
/**
* Subscribe an obvers.
- *
+ *
* @param aObserver
* Observer to subscribe.
* @return Event Event to send.
*/
- public synchronized long subscribe(
- Observer<ObservableType, Event> aObserver) {
+ public synchronized long subscribe(Observer<ObservableType, Event> aObserver) {
long subscription = counter++; // integer rage is so large it will
- // never roll over.
+ // never roll over.
observers.put(subscription, aObserver);
/**
* Unsubscribe an observer.
- *
+ *
* @param aSubscription
* Subscription which is used
* @throws IllegalArgumentException
/**
* Gets the number of subscribed observers.
- *
+ *
* @return Number of subscribed observers.
*/
public int getObserverCount() {
/**
* Notifies all subscribed observers.
- *
+ *
* @param aEvent
* Event to send.
*/
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#finalize()
*/
@Override
protected void finalize() throws Throwable {
if (observers.size() > 0) {
- LOGGER.error(
- "Still observers registered at finalization of observer!");
+ LOGGER
+ .error("Still observers registered at finalization of observer!");
for (Observer observer : observers.values()) {
LOGGER.error(" observer: " + observer);