Skip to content
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

To address the API review comments #27511

Original file line number Diff line number Diff line change
Expand Up @@ -399,22 +399,17 @@ the main ServiceBusClientBuilder. -->

<!-- TODO: only use for merging pr temporary, need to fix.-->
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.ConsumerProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.merger.ProcessorPropertiesParentMerger"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.merger.ProducerPropertiesParentMerger"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.NamespaceProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.ProcessorProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.ProducerProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.eventhubs.core.properties.ProducerProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.CommonProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.ConsumerProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.merger.ProcessorPropertiesParentMerger"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.merger.SenderPropertiesParentMerger"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.NamespaceProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.ProcessorProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.servicebus.core.properties.ProducerProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.messaging.storage.queue.core.properties.StorageQueueProperties"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.cloud.autoconfigure.aadb2c.AadB2cJwtBearerTokenAuthenticationConverter"/>
<suppress checks="com.azure.tools.checkstyle.checks.NoImplInPublicAPI" files="com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase"/>

<!-- TODO: (https://github.com/Azure/azure-sdk-for-java/issues/18291) -->
<!-- GoodLoggingCheck: Spring as a framework, will not directly use ClientLogger-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
package com.azure.spring.cloud.autoconfigure.aad.properties;

import com.azure.core.management.AzureEnvironment;
import com.azure.spring.cloud.core.aware.AzureProfileOptionsAware;
import com.azure.spring.cloud.core.properties.profile.AzureProfileAdapter;
import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider;
import com.azure.spring.cloud.core.properties.profile.AzureProfileOptionsAdapter;

/**
* Properties to Azure Active Directory endpoints.
Expand Down Expand Up @@ -57,8 +57,8 @@ public void setMicrosoftGraphEndpoint(String microsoftGraphEndpoint) {
*
* @param cloudType The cloud type.
*/
public void updatePropertiesByCloudType(AzureProfileOptionsAware.CloudType cloudType) {
AzureEnvironment knownAzureEnvironment = AzureProfileAdapter.decideManagementAzureEnvironment(cloudType, AzureEnvironment.AZURE);
public void updatePropertiesByCloudType(AzureProfileOptionsProvider.CloudType cloudType) {
AzureEnvironment knownAzureEnvironment = AzureProfileOptionsAdapter.decideAzureManagementEnvironment(cloudType, AzureEnvironment.AZURE);
if (this.activeDirectoryEndpoint == null) {
this.activeDirectoryEndpoint = knownAzureEnvironment.getActiveDirectoryEndpoint();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.spring.cloud.autoconfigure.aad.properties;


import com.azure.spring.cloud.core.aware.AzureProfileOptionsAware;
import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider;
import org.springframework.boot.context.properties.NestedConfigurationProperty;


Expand All @@ -21,7 +21,7 @@ public class AadProfileProperties {
* Name of the Azure cloud to connect to.
* Supported types are: AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT, OTHER.
*/
private AzureProfileOptionsAware.CloudType cloudType;
private AzureProfileOptionsProvider.CloudType cloudType;
/**
* Properties to Azure Active Directory endpoints.
*/
Expand All @@ -48,15 +48,15 @@ public void setTenantId(String tenantId) {
*
* @return The cloud type.
*/
public AzureProfileOptionsAware.CloudType getCloudType() {
public AzureProfileOptionsProvider.CloudType getCloudType() {
return cloudType;
}

/**
*
* @param cloudType The cloud type.
*/
public void setCloudType(AzureProfileOptionsAware.CloudType cloudType) {
public void setCloudType(AzureProfileOptionsProvider.CloudType cloudType) {
this.cloudType = cloudType;
environment.updatePropertiesByCloudType(cloudType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import com.azure.data.appconfiguration.ConfigurationClient;
import com.azure.data.appconfiguration.ConfigurationClientBuilder;
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.implementation.appconfiguration.AzureAppConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.autoconfigure.implementation.appconfiguration.AzureAppConfigurationProperties;
import com.azure.spring.cloud.core.AzureSpringIdentifier;
import com.azure.spring.cloud.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.cloud.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.cloud.core.provider.connectionstring.ServiceConnectionStringProvider;
import com.azure.spring.cloud.core.provider.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.cloud.core.service.AzureServiceType;
import com.azure.spring.cloud.service.implementation.appconfiguration.ConfigurationClientBuilderFactory;
Expand Down Expand Up @@ -41,12 +41,22 @@ AzureAppConfigurationProperties azureAppConfigurationProperties() {
return loadProperties(this.azureGlobalProperties, new AzureAppConfigurationProperties());
}

/**
* Autoconfigure the {@link ConfigurationClient} instance.
* @param builder The {@link ConfigurationClientBuilder} to build the instance.
* @return the configuration client instance.
*/
@Bean
@ConditionalOnMissingBean
public ConfigurationClient azureConfigurationClient(ConfigurationClientBuilder builder) {
return builder.buildClient();
}

/**
* Autoconfigure the {@link ConfigurationAsyncClient} instance.
* @param builder The {@link ConfigurationClientBuilder} to build the instance.
* @return the configuration async client instance.
*/
@Bean
@ConditionalOnMissingBean
public ConfigurationAsyncClient azureConfigurationAsyncClient(ConfigurationClientBuilder builder) {
Expand All @@ -63,7 +73,7 @@ ConfigurationClientBuilder configurationClientBuilder(ConfigurationClientBuilder
@ConditionalOnMissingBean
ConfigurationClientBuilderFactory configurationClientBuilderFactory(
AzureAppConfigurationProperties properties,
ObjectProvider<ConnectionStringProvider<AzureServiceType.AppConfiguration>> connectionStringProviders,
ObjectProvider<ServiceConnectionStringProvider<AzureServiceType.AppConfiguration>> connectionStringProviders,
ObjectProvider<AzureServiceClientBuilderCustomizer<ConfigurationClientBuilder>> customizers) {
ConfigurationClientBuilderFactory factory = new ConfigurationClientBuilderFactory(properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.spring.cloud.autoconfigure.compatibility;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Arrays;
import java.util.List;

Expand All @@ -12,24 +13,44 @@
*/
@ConfigurationProperties("spring.cloud.azure.compatibility-verifier")
public class SpringCloudAzureCompatibilityVerifierProperties {

/**
* Whether to enable the Spring Cloud Azure compatibility verifier.
*/
private boolean enabled;
/**
* Comma-delimited list of Spring Boot versions that are compatible with current Spring Cloud Azure's version.
*/
private List<String> compatibleBootVersions = Arrays.asList("2.5.x", "2.6.x");

public SpringCloudAzureCompatibilityVerifierProperties() {
}

/**
* Whether to enable the Spring Cloud Azure compatibility verifier.
* @return whether to enable the Spring Cloud Azure compatibility verifier.
*/
public boolean isEnabled() {
return this.enabled;
}

/**
* Set whether to enable the Spring Cloud Azure compatibility verifier.
* @param enabled whether to enable the Spring Cloud Azure compatibility verifier.
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

/**
* Get the list of Spring Boot versions that are compatible with current Spring Cloud Azure's version.
* @return the compatible Spring Boot versions.
*/
public List<String> getCompatibleBootVersions() {
return this.compatibleBootVersions;
}

/**
* Set the list of Spring Boot versions that are compatible with current Spring Cloud Azure's version.
* @param compatibleBootVersions the compatible Spring Boot versions.
*/
public void setCompatibleBootVersions(List<String> compatibleBootVersions) {
this.compatibleBootVersions = compatibleBootVersions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@
import com.azure.spring.cloud.autoconfigure.properties.core.profile.AzureProfileConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.core.proxy.ProxyConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.core.retry.RetryConfigurationProperties;
import com.azure.spring.cloud.core.aware.RetryOptionsAware;
import com.azure.spring.cloud.core.provider.RetryOptionsProvider;
import com.azure.spring.cloud.core.properties.AzureProperties;
import com.azure.spring.cloud.core.properties.client.HeaderProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

/**
*
*/
@ConfigurationProperties(prefix = AzureGlobalProperties.PREFIX)
public class AzureGlobalProperties implements AzureProperties, RetryOptionsAware {
public class AzureGlobalProperties implements AzureProperties, RetryOptionsProvider {

public static final String PREFIX = "spring.cloud.azure";

Expand Down Expand Up @@ -198,6 +201,11 @@ public static final class GlobalHttpClientConfigurationProperties {
*/
private Duration connectionIdleTimeout;

/**
* Comma-delimited list of headers applied to each request sent with client.
*/
private final List<HeaderProperties> headers = new ArrayList<>();

@NestedConfigurationProperty
private final HttpLoggingConfigurationProperties logging = new HttpLoggingConfigurationProperties();

Expand Down Expand Up @@ -249,6 +257,10 @@ public void setConnectionIdleTimeout(Duration connectionIdleTimeout) {
this.connectionIdleTimeout = connectionIdleTimeout;
}

public List<HeaderProperties> getHeaders() {
return headers;
}

public HttpLoggingConfigurationProperties getLogging() {
return logging;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.azure.identity.UsernamePasswordCredentialBuilder;
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.implementation.properties.core.AbstractAzureHttpConfigurationProperties;
import com.azure.spring.cloud.core.aware.authentication.TokenCredentialOptionsAware;
import com.azure.spring.cloud.core.provider.authentication.TokenCredentialOptionsProvider;
import com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.cloud.core.implementation.credential.resolver.AzureTokenCredentialResolver;
import com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory;
Expand Down Expand Up @@ -82,7 +82,7 @@ AzureTokenCredentialResolver azureTokenCredentialResolver(
return null;
}

final TokenCredentialOptionsAware.TokenCredential properties = azureProperties.getCredential();
final TokenCredentialOptionsProvider.TokenCredentialOptions properties = azureProperties.getCredential();
final String tenantId = azureProperties.getProfile().getTenantId();
final String clientId = properties.getClientId();
final boolean isClientIdSet = StringUtils.hasText(clientId);
Expand Down Expand Up @@ -187,6 +187,10 @@ UsernamePasswordCredentialBuilderFactory usernamePasswordCredentialBuilderFactor
return factory;
}

/**
* The BeanPostProcessor to apply the default token credential to all service client builder factories.
* @return the BPP.
*/
@Bean
public static AzureServiceClientBuilderFactoryPostProcessor builderFactoryBeanPostProcessor() {
return new AzureServiceClientBuilderFactoryPostProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.implementation.cosmos.properties.AzureCosmosProperties;
import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.autoconfigure.implementation.cosmos.properties.AzureCosmosProperties;
import com.azure.spring.cloud.core.AzureSpringIdentifier;
import com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.cloud.service.implementation.cosmos.CosmosClientBuilderFactory;
Expand Down Expand Up @@ -38,12 +38,22 @@ AzureCosmosProperties azureCosmosProperties() {
return loadProperties(this.azureGlobalProperties, new AzureCosmosProperties());
}

/**
* Autoconfigure the {@link CosmosClient} instance.
* @param builder the {@link CosmosClientBuilder} to build the instance.
* @return the cosmos client instance.
*/
@Bean
@ConditionalOnMissingBean
public CosmosClient azureCosmosClient(CosmosClientBuilder builder) {
return builder.buildClient();
}

/**
* Autoconfigure the {@link CosmosAsyncClient} instance.
* @param builder the {@link CosmosClientBuilder} to build the instance.
* @return the cosmos async client instance.
*/
@Bean
@ConditionalOnMissingBean
// TODO (xiada): spring data cosmos also defines a CosmosAsyncClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ BlobCheckpointStore blobCheckpointStore(
return new BlobCheckpointStore(blobContainerAsyncClient);
}

/**
* The default {@link BlobCheckpointStoreContainerInitializer} to create the storage blob if not exists.
* @return the default {@link BlobCheckpointStoreContainerInitializer}.
*/
@Bean
@ConditionalOnProperty(value = "spring.cloud.azure.eventhubs.processor.checkpoint-store.create-container-if-not-exists", havingValue = "true")
public BlobCheckpointStoreContainerInitializer blobCheckpointStoreContainerCreationInitializer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.implementation.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.cloud.autoconfigure.context.AzureGlobalProperties;
import com.azure.spring.cloud.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.cloud.core.provider.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.cloud.core.service.AzureServiceType;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.implementation.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.cloud.core.AzureSpringIdentifier;
import com.azure.spring.cloud.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.cloud.core.provider.connectionstring.ServiceConnectionStringProvider;
import com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.cloud.core.service.AzureServiceType;
import com.azure.spring.cloud.service.implementation.eventhubs.factory.EventHubClientBuilderFactory;
Expand Down Expand Up @@ -39,7 +39,7 @@ EventHubClientBuilder eventHubClientBuilder(@Qualifier(EVENT_HUB_CLIENT_BUILDER_
@Bean(EVENT_HUB_CLIENT_BUILDER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean
EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubsProperties properties,
ObjectProvider<ConnectionStringProvider<AzureServiceType.EventHubs>> connectionStringProviders,
ObjectProvider<ServiceConnectionStringProvider<AzureServiceType.EventHubs>> connectionStringProviders,
ObjectProvider<AzureServiceClientBuilderCustomizer<EventHubClientBuilder>> customizers) {
final EventHubClientBuilderFactory factory = new EventHubClientBuilderFactory(properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
import com.azure.spring.cloud.autoconfigure.implementation.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.cloud.core.AzureSpringIdentifier;
import com.azure.spring.cloud.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.cloud.core.provider.connectionstring.ServiceConnectionStringProvider;
import com.azure.spring.cloud.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.cloud.core.service.AzureServiceType;
import com.azure.spring.cloud.service.implementation.eventhubs.factory.EventHubClientBuilderFactory;
Expand Down Expand Up @@ -82,7 +82,7 @@ static class DedicatedConsumerConnectionConfiguration {
@Bean(EVENT_HUB_CONSUMER_CLIENT_BUILDER_FACTORY_BEAN_NAME)
@ConditionalOnMissingBean(name = EVENT_HUB_CONSUMER_CLIENT_BUILDER_FACTORY_BEAN_NAME)
EventHubClientBuilderFactory eventHubClientBuilderFactoryForConsumer(
ObjectProvider<ConnectionStringProvider<AzureServiceType.EventHubs>> connectionStringProviders,
ObjectProvider<ServiceConnectionStringProvider<AzureServiceType.EventHubs>> connectionStringProviders,
ObjectProvider<AzureServiceClientBuilderCustomizer<EventHubClientBuilder>> customizers) {

final EventHubClientBuilderFactory factory = new EventHubClientBuilderFactory(this.consumerProperties);
Expand Down
Loading