All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.event.feed.DelegatingPollHandler Maven / Gradle / Ivy

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.event.feed;

import java.util.List;

import com.google.common.collect.ImmutableList;

/**
 * A poll handler that delegates each call to a set of poll handlers.
 * 
 * @author aled
 */
public class DelegatingPollHandler implements PollHandler {

    private final List> delegates;

    public DelegatingPollHandler(Iterable> delegates) {
        super();
        this.delegates = ImmutableList.copyOf(delegates);
    }

    @Override
    public boolean checkSuccess(V val) {
        for (AttributePollHandler delegate : delegates) {
            if (!delegate.checkSuccess(val))
                return false;
        }
        return true;
    }

    @Override
    public void onSuccess(V val) {
        for (AttributePollHandler delegate : delegates) {
            delegate.onSuccess(val);
        }
    }

    @Override
    public void onFailure(V val) {
        for (AttributePollHandler delegate : delegates) {
            delegate.onFailure(val);
        }
    }

    @Override
    public void onError(Exception error) {
        onException(error);
    }

    @Override
    public void onException(Exception exception) {
        for (AttributePollHandler delegate : delegates) {
            delegate.onException(exception);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy