forked from aws/aws-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This release introduces a new type of POJO attribute - S3Link for DynamoDBMapper, and also updates the Amazon CloudFront client with support for customizing error responses.
- Loading branch information
1 parent
d26ff1f
commit e38176c
Showing
217 changed files
with
11,770 additions
and
2,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/com/amazonaws/event/ProgressListenerCallbackExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2010-2013 Amazon.com, 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 | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
package com.amazonaws.event; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
|
||
/** | ||
* This class wraps a ProgressListener object, and manages all its callback | ||
* execution. Callbacks are executed sequentially in a separate single thread. | ||
*/ | ||
public class ProgressListenerCallbackExecutor { | ||
|
||
/** The wrapped ProgressListener **/ | ||
private final ProgressListener listener; | ||
|
||
/** A single thread pool for executing ProgressListener callback. **/ | ||
private ExecutorService executor; | ||
|
||
public ProgressListenerCallbackExecutor(ProgressListener listener) { | ||
this.listener = listener; | ||
} | ||
|
||
public void progressChanged(final ProgressEvent progressEvent) { | ||
if (listener == null) return; | ||
|
||
synchronized (this) { | ||
if (executor == null) { | ||
executor = Executors.newSingleThreadExecutor(); | ||
} | ||
executor.submit(new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
listener.progressChanged(progressEvent); | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
public synchronized void shutDown() { | ||
if (executor != null) { | ||
executor.shutdown(); | ||
} | ||
} | ||
|
||
/** | ||
* Returns a new ProgressListenerCallbackExecutor instance that wraps the | ||
* specified ProgressListener if it is not null, otherwise directly returns | ||
* null. | ||
*/ | ||
public static ProgressListenerCallbackExecutor wrapListener(ProgressListener listener) { | ||
return listener == null ? | ||
null : new ProgressListenerCallbackExecutor(listener); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/amazonaws/event/ProgressListenerChain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2010-2013 Amazon.com, 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 | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* 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; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
/** | ||
* An implementation of ProgressListener interface that delegates | ||
* progressChanged callback to multiple listeners. | ||
* <p> | ||
* This class could be used for both Amazon S3 and Amazon Glacier clients. The | ||
* legacy Amazon S3 progress listener chain | ||
* {@link com.amazonaws.services.s3.transfer.internal.ProgressListenerChain} is | ||
* deprecated in favor of this new class. | ||
* </p> | ||
*/ | ||
public class ProgressListenerChain implements ProgressListener { | ||
private final List<ProgressListener> listeners = new CopyOnWriteArrayList<ProgressListener>(); | ||
|
||
private static final Log log = LogFactory.getLog(ProgressListenerChain.class); | ||
|
||
public ProgressListenerChain(ProgressListener... listeners) { | ||
for (ProgressListener listener : listeners) addProgressListener(listener); | ||
} | ||
|
||
public synchronized void addProgressListener(ProgressListener listener) { | ||
if (listener == null) return; | ||
this.listeners.add(listener); | ||
} | ||
|
||
public synchronized void removeProgressListener(ProgressListener listener) { | ||
if (listener == null) return; | ||
this.listeners.remove(listener); | ||
} | ||
|
||
public void progressChanged(final ProgressEvent progressEvent) { | ||
for ( ProgressListener listener : listeners ) { | ||
try { | ||
listener.progressChanged(progressEvent); | ||
} catch ( RuntimeException e ) { | ||
log.warn("Couldn't update progress listener", e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.