diff --git a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3AutoConfiguration.java b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3AutoConfiguration.java index e2a91f384..b84345952 100644 --- a/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3AutoConfiguration.java +++ b/spring-cloud-aws-autoconfigure/src/main/java/io/awspring/cloud/autoconfigure/s3/S3AutoConfiguration.java @@ -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; @@ -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 diff --git a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3ProtocolResolver.java b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3ProtocolResolver.java index 6a4ef2ed5..1d8a2b24e 100644 --- a/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3ProtocolResolver.java +++ b/spring-cloud-aws-s3/src/main/java/io/awspring/cloud/s3/S3ProtocolResolver.java @@ -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; /** @@ -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; diff --git a/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ProtocolResolverTests.java b/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ProtocolResolverTests.java index 5f9f73603..2cffd7499 100644 --- a/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ProtocolResolverTests.java +++ b/spring-cloud-aws-s3/src/test/java/io/awspring/cloud/s3/S3ProtocolResolverTests.java @@ -36,7 +36,7 @@ import software.amazon.awssdk.services.s3.S3Client; /** - * Tests for {@link S3ProtocolResolverTests}. + * Tests for {@link S3ProtocolResolver}. * * @author Maciej Walkowiak */