Skip to content

Add a constructor to S3ProtocolResolver allowing its usage outside of Spring context #1276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Optional;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.PropertyMapper;
Expand All @@ -53,7 +52,7 @@
import software.amazon.encryption.s3.S3EncryptionClient;

/**
* {@link EnableAutoConfiguration} for {@link S3Client} and {@link S3ProtocolResolver}.
* {@link AutoConfiguration} for {@link S3Client} and {@link S3ProtocolResolver}.
*
* @author Maciej Walkowiak
* @author Matej Nedic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import software.amazon.awssdk.services.s3.S3Client;

/**
Expand Down Expand Up @@ -54,6 +55,14 @@ public class S3ProtocolResolver implements ProtocolResolver, ResourceLoaderAware
public S3ProtocolResolver() {
}

// for direct usages outside of Spring context, when BeanFactory is not available
public S3ProtocolResolver(S3Client s3Client, S3OutputStreamProvider s3OutputStreamProvider) {
Assert.notNull(s3Client, "s3Client is required");
Assert.notNull(s3OutputStreamProvider, "s3OutputStreamProvider is required");
this.s3Client = s3Client;
this.s3OutputStreamProvider = s3OutputStreamProvider;
}

// only for testing
S3ProtocolResolver(@Nullable S3Client s3Client) {
this.s3Client = s3Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import software.amazon.awssdk.services.s3.S3Client;

/**
* Tests for {@link S3ProtocolResolverTests}.
* Tests for {@link S3ProtocolResolver}.
*
* @author Maciej Walkowiak
*/
Expand Down
Loading