Skip to content

Commit

Permalink
Add a constructor to S3ProtocolResolver allowing its usage outside of…
Browse files Browse the repository at this point in the history
… Spring context
  • Loading branch information
klach-ocado committed Nov 15, 2024
1 parent 6151537 commit 4d64dbf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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

0 comments on commit 4d64dbf

Please sign in to comment.