com.zipwhip.concurrent.OnlyRunIfSuccessfulObserverAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zipwhip-api Show documentation
Show all versions of zipwhip-api Show documentation
Java client to support applications powered by the Zipwhip Cloud
The newest version!
package com.zipwhip.concurrent;
import com.zipwhip.events.Observer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Created with IntelliJ IDEA.
* User: Michael
* Date: 9/10/12
* Time: 6:15 PM
* To change this template use File | Settings | File Templates.
*/
public class OnlyRunIfSuccessfulObserverAdapter extends ObserverAdapter> {
private static final Logger LOGGER = LoggerFactory.getLogger(OnlyRunIfSuccessfulObserverAdapter.class);
public OnlyRunIfSuccessfulObserverAdapter(Observer> observer) {
super(observer);
}
@Override
public void notify(Object sender, ObservableFuture future) {
synchronized (future) {
if (future.isSuccess()) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(String.format("Successful, so notifying %s of %s", getObserver(), future));
}
super.notify(sender, future);
} else {
LOGGER.warn(String.format("Not successful, so not notifying %s of %s", getObserver(), future));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy