From d4813b99accc8214b16763705adb15e97061cd81 Mon Sep 17 00:00:00 2001 From: jitkukum Date: Tue, 1 Aug 2023 12:29:45 +0530 Subject: [PATCH] Remove ambiguity on region Provider bean Removing 2.7.x from support matrix in main readme --- README.md | 7 +++---- .../core/CredentialsProviderAutoConfiguration.java | 4 +++- .../core/RegionProviderAutoConfiguration.java | 3 ++- .../cloud/spring/logging/LoggingAutoConfiguration.java | 7 ++++++- .../notification/NotificationAutoConfiguration.java | 10 ++++++++-- .../cloud/spring/storage/StorageAutoConfiguration.java | 7 ++++++- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5098981d..40e62d0f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > **Warning** > > Code in this repository is work-in-progress and has not been released officially. -> +> > Not recommended for personal or production use at this point. ## Introduction @@ -19,7 +19,7 @@ For a deep dive into the project, refer to the Spring Cloud OCI documentation: | Version | Reference Docs | API Docs | |------------------------|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------| -| Spring Cloud OCI 1.0.0 | [Reference Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/reference/html/index.html) | [API Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/javadocs/index.html) | +| Spring Cloud OCI 1.0.0 | [Reference Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/reference/html/index.html) | [API Docs](https://oracle.github.io/spring-cloud-oci/1.0.0/javadocs/index.html) | ## Compatibility with Spring Project Versions @@ -28,7 +28,7 @@ This project has dependency and transitive dependencies on Spring Projects. The | Spring Cloud OCI | Spring Cloud | Spring Boot | OCI Java SDK | |-------------------|-----------------|---------------------|--------------| -| 1.0.0 | | 2.7.x, 3.0.x, 3.1.x | 3.19.0 | +| 1.0.0 | | 3.0.x, 3.1.x | 3.19.0 | ## Try out samples @@ -102,4 +102,3 @@ Copyright (c) 2023 Oracle and/or its affiliates. Released under the Universal Permissive License v1.0 as shown at . - diff --git a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProviderAutoConfiguration.java b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProviderAutoConfiguration.java index dfddf359..f63500f0 100644 --- a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProviderAutoConfiguration.java +++ b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/CredentialsProviderAutoConfiguration.java @@ -29,6 +29,8 @@ @EnableConfigurationProperties(CredentialsProperties.class) public class CredentialsProviderAutoConfiguration { + public static final String credentialsProviderQualifier = "credentialsProvider"; + private static final String PROFILE_DEFAULT = "DEFAULT"; private final CredentialsProperties properties; @@ -41,7 +43,7 @@ public CredentialsProviderAutoConfiguration(CredentialsProperties properties) { * @return * @throws IOException */ - @Bean + @Bean (name = credentialsProviderQualifier) @ConditionalOnMissingBean public BasicAuthenticationDetailsProvider credentialsProvider() throws IOException { return createCredentialsProvider(properties); diff --git a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/RegionProviderAutoConfiguration.java b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/RegionProviderAutoConfiguration.java index bb920c51..63673b37 100644 --- a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/RegionProviderAutoConfiguration.java +++ b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/autoconfigure/core/RegionProviderAutoConfiguration.java @@ -22,13 +22,14 @@ @EnableConfigurationProperties(RegionProperties.class) public class RegionProviderAutoConfiguration { + public static final String regionProviderQualifier = "regionProvider"; private final RegionProperties properties; public RegionProviderAutoConfiguration(RegionProperties properties) { this.properties = properties; } - @Bean + @Bean (name = regionProviderQualifier) @ConditionalOnMissingBean public RegionProvider regionProvider() { return createRegionProvider(properties); diff --git a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/logging/LoggingAutoConfiguration.java b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/logging/LoggingAutoConfiguration.java index c85aed2a..296764c3 100644 --- a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/logging/LoggingAutoConfiguration.java +++ b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/logging/LoggingAutoConfiguration.java @@ -8,6 +8,7 @@ import com.oracle.bmc.auth.BasicAuthenticationDetailsProvider; import com.oracle.bmc.auth.RegionProvider; import com.oracle.bmc.loggingingestion.LoggingClient; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -15,6 +16,9 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; +import static com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration.credentialsProviderQualifier; +import static com.oracle.cloud.spring.autoconfigure.core.RegionProviderAutoConfiguration.regionProviderQualifier; + /** * Auto-configuration for initializing the OCI Logging component. * Depends on {@link com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration} and @@ -43,7 +47,8 @@ Logging getLoggingImpl(com.oracle.bmc.loggingingestion.Logging logging) { @Bean @ConditionalOnMissingBean - com.oracle.bmc.loggingingestion.Logging loggingClient(RegionProvider regionProvider, + com.oracle.bmc.loggingingestion.Logging loggingClient(@Qualifier(regionProviderQualifier) RegionProvider regionProvider, + @Qualifier(credentialsProviderQualifier) BasicAuthenticationDetailsProvider adp) { com.oracle.bmc.loggingingestion.Logging logging = new LoggingClient(adp); if (regionProvider.getRegion() != null) logging.setRegion(regionProvider.getRegion()); diff --git a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/notification/NotificationAutoConfiguration.java b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/notification/NotificationAutoConfiguration.java index b2d0e1ca..0cca353b 100644 --- a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/notification/NotificationAutoConfiguration.java +++ b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/notification/NotificationAutoConfiguration.java @@ -11,12 +11,16 @@ import com.oracle.bmc.ons.NotificationControlPlaneClient; import com.oracle.bmc.ons.NotificationDataPlane; import com.oracle.bmc.ons.NotificationDataPlaneClient; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; +import static com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration.credentialsProviderQualifier; +import static com.oracle.cloud.spring.autoconfigure.core.RegionProviderAutoConfiguration.regionProviderQualifier; + /** * Auto-configuration for initializing the OCI Notification component. * Depends on {@link com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration} and @@ -38,7 +42,8 @@ Notification getNotificationImpl(NotificationDataPlane notificationDataPlane, No @Bean @ConditionalOnMissingBean - NotificationDataPlane notificationDataPlaneClient(RegionProvider regionProvider, + NotificationDataPlane notificationDataPlaneClient(@Qualifier(regionProviderQualifier) RegionProvider regionProvider, + @Qualifier(credentialsProviderQualifier) BasicAuthenticationDetailsProvider adp) { NotificationDataPlane notificationDataPlaneClient = new NotificationDataPlaneClient(adp); if (regionProvider.getRegion() != null) notificationDataPlaneClient.setRegion(regionProvider.getRegion()); @@ -47,7 +52,8 @@ NotificationDataPlane notificationDataPlaneClient(RegionProvider regionProvider, @Bean @ConditionalOnMissingBean - NotificationControlPlane notificationControlPlaneClient(RegionProvider regionProvider, + NotificationControlPlane notificationControlPlaneClient(@Qualifier(regionProviderQualifier) RegionProvider regionProvider, + @Qualifier(credentialsProviderQualifier) BasicAuthenticationDetailsProvider adp) { NotificationControlPlane notificationControlPlaneClient = new NotificationControlPlaneClient(adp); if (regionProvider.getRegion() != null) notificationControlPlaneClient.setRegion(regionProvider.getRegion()); diff --git a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/storage/StorageAutoConfiguration.java b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/storage/StorageAutoConfiguration.java index 9997d52f..d7a88087 100644 --- a/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/storage/StorageAutoConfiguration.java +++ b/spring-cloud-oci-autoconfigure/src/main/java/com/oracle/cloud/spring/storage/StorageAutoConfiguration.java @@ -10,6 +10,7 @@ import com.oracle.bmc.auth.RegionProvider; import com.oracle.bmc.objectstorage.ObjectStorageClient; import com.oracle.cloud.spring.core.compartment.CompartmentProvider; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -20,6 +21,9 @@ import java.util.Optional; +import static com.oracle.cloud.spring.autoconfigure.core.CredentialsProviderAutoConfiguration.credentialsProviderQualifier; +import static com.oracle.cloud.spring.autoconfigure.core.RegionProviderAutoConfiguration.regionProviderQualifier; + /** * Auto-configuration for initializing the OCI Storage component. * Depends on {@link com.oracle.cloud.spring.autoconfigure.core.CompartmentProviderAutoConfiguration}, @@ -48,7 +52,8 @@ Storage storageActions(ObjectStorageClient osClient, StorageOutputStreamProvider @Bean @ConditionalOnMissingBean - ObjectStorageClient objectStorageClient(RegionProvider regionProvider, + ObjectStorageClient objectStorageClient(@Qualifier(regionProviderQualifier) RegionProvider regionProvider, + @Qualifier(credentialsProviderQualifier) BasicAuthenticationDetailsProvider adp) { ObjectStorageClient osClient = new ObjectStorageClient(adp); if (regionProvider.getRegion() != null) osClient.setRegion(regionProvider.getRegion());