Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Copyright 2010-2015, Inc. or its affiliates. All Rights Reserved.
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
  * or in the "license" file accompanying this file. This file is distributed
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
 package com.amazonaws.event;
 import java.util.List;
An implementation of ProgressListener interface that delegates progressChanged callback to multiple listeners. It also takes an optional ProgressEventFilter to filter incoming events before passing them to the listeners.

This class could be used for both Amazon S3 and Amazon Glacier clients. The legacy Amazon S3 progress listener chain has been deprecated in favor of this new class.

 public class ProgressListenerChain implements ProgressListenerDeliveryMode {
     private static final Log log = LogFactory.getLog(ProgressListenerChain.class);
     private final List<ProgressListenerlisteners = new CopyOnWriteArrayList<ProgressListener>();
     private final ProgressEventFilter progressEventFilter;
True if synchronous callback to every listener in this chain is safe with no risk of incurring undue latency.

     private volatile boolean syncCallSafe = true;

Create a listener chain that directly passes all the progress events to the specified listeners.
     public ProgressListenerChain(ProgressListener... listeners) {

Create a listener chain with a ProgressEventFilter.
     public ProgressListenerChain(ProgressEventFilter progressEventFilterProgressListener... listeners) {
         if (listeners == null) {
             throw new IllegalArgumentException(
                     "Progress Listeners cannot be null.");
         for (ProgressListener listener : listeners)
         this. = progressEventFilter;
     public synchronized void addProgressListener(ProgressListener listener) {
         if (listener == null
         if ()
              = DeliveryMode.Check.isSyncCallSafe(listener);
     public synchronized void removeProgressListener(ProgressListener listener) {
         if (listener == nullreturn;

Returns the listeners associated with this listener chain.
     protected List<ProgressListenergetListeners() {
         return ;
     public void progressChanged(final ProgressEvent progressEvent) {
         ProgressEvent filteredEvent = progressEvent;
         if ( != null) {
             filteredEvent = .filter(progressEvent);
             if (filteredEvent == nullreturn;
         for ( ProgressListener listener :  ) {
             try {
             } catch ( RuntimeException e ) {
                .warn("Couldn't update progress listener"e);
    @Override public boolean isSyncCallSafe() { return ; }
New to GrepCode? Check out our FAQ X