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

Spring Cloud Azure 4.0 refactor application-id and spring-identifier #24759

Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -9,6 +9,7 @@
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -48,6 +49,7 @@ public ConfigurationAsyncClient azureConfigurationAsyncClient(ConfigurationClien
@Bean
@ConditionalOnMissingBean
public ConfigurationClientBuilder configurationClientBuilder(ConfigurationClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_APP_CONFIG);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.azure.core.util.Configuration;
import com.azure.cosmos.ConnectionMode;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.credential.descriptor.AuthenticationDescriptor;
import com.azure.spring.core.credential.descriptor.KeyAuthenticationDescriptor;
import com.azure.spring.core.credential.descriptor.TokenAuthenticationDescriptor;
Expand Down Expand Up @@ -53,11 +52,6 @@ protected List<AuthenticationDescriptor<?>> getAuthenticationDescriptors(CosmosC
);
}

@Override
protected void configureApplicationId(CosmosClientBuilder builder) {
builder.userAgentSuffix(ApplicationId.AZURE_SPRING_COSMOS);
}

@Override
protected void configureProxy(CosmosClientBuilder builder) {
LOGGER.debug("No configureProxy for CosmosClientBuilder.");
Expand Down Expand Up @@ -96,6 +90,11 @@ protected void configureService(CosmosClientBuilder builder) {
}
}

@Override
protected BiConsumer<CosmosClientBuilder, String> consumeApplicationId() {
return CosmosClientBuilder::userAgentSuffix;
}

@Override
protected BiConsumer<CosmosClientBuilder, Configuration> consumeConfiguration() {
LOGGER.warn("Configuration instance is not supported to configure in CosmosClientBuilder");
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.eventhubs.factory.EventHubClientBuilderFactory;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
Expand Down Expand Up @@ -39,7 +39,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactory(AzureEventHubPr
final EventHubClientBuilderFactory builderFactory = new EventHubClientBuilderFactory(properties);

builderFactory.setConnectionStringProvider(connectionStringProviders.getIfAvailable());
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return builderFactory;
}

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.eventhubs.factory.EventHubClientBuilderFactory;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -74,7 +74,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactoryForConsumer() {

builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB,
this.consumerProperties.getConnectionString()));
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return builderFactory;
}

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.eventhubs.factory.EventHubClientBuilderFactory;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import com.azure.spring.eventhubs.core.EventHubOperation;
Expand Down Expand Up @@ -67,7 +67,7 @@ public EventHubClientBuilderFactory eventHubClientBuilderFactoryForProducer() {

builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.EVENT_HUB,
this.producerProperties.getConnectionString()));
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_EVENT_HUB);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return builderFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.azure.spring.cloud.autoconfigure.eventhubs.factory.EventHubSharedAuthenticationClientBuilderFactory;
import com.azure.spring.cloud.autoconfigure.eventhubs.factory.EventProcessorSharedAuthenticationClientBuilderFactory;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import com.azure.spring.eventhubs.core.EventHubOperation;
Expand Down Expand Up @@ -39,6 +40,7 @@ static class EventHubServiceClientConfiguration {
@ConditionalOnMissingBean
public EventHubSharedAuthenticationClientBuilder eventHubSharedAuthenticationClientBuilder(
EventHubSharedAuthenticationClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return factory.build();
}

Expand All @@ -62,6 +64,7 @@ static class EventProcessorServiceClientConfiguration {
@ConditionalOnMissingBean
public EventProcessorSharedAuthenticationClientBuilder eventProcessorSharedAuthenticationClientBuilder(
EventProcessorSharedAuthenticationClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_EVENT_HUB);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,4 @@ protected List<AuthenticationDescriptor<?>> getAuthenticationDescriptors(EventHu
);
}

@Override
protected String getApplicationId() {
return super.getApplicationId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import javax.jms.ConnectionFactory;

import static com.azure.spring.core.ApplicationId.AZURE_SPRING_SERVICE_BUS;
import static com.azure.spring.core.ApplicationId.VERSION;
import static com.azure.spring.core.AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS;
import static com.azure.spring.core.AzureSpringIdentifier.VERSION;

/**
* Automatic configuration class of ServiceBusJMS for Premium Service Bus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public CertificateAsyncClient azureKeyVaultCertificateAsyncClient(CertificateCli
@Bean
@ConditionalOnMissingBean
public CertificateClientBuilder certificateClientBuilder(CertificateClientBuilderFactory factory) {
// TODO (xiada): how to distinguish this from kv secrets?
// factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_KEY_VAULT);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand Down Expand Up @@ -49,6 +50,7 @@ public SecretAsyncClient azureKeyVaultSecretAsyncClient(SecretClientBuilder buil
@Bean
@ConditionalOnMissingBean
public SecretClientBuilder secretClientBuilder(SecretClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_KEY_VAULT);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
Expand Down Expand Up @@ -35,10 +35,10 @@ class AzureServiceBusClientBuilderConfiguration {
public ServiceBusClientBuilderFactory serviceBusClientBuilderFactory(
ObjectProvider<ConnectionStringProvider<AzureServiceType.ServiceBus>> connectionStringProviders) {

final ServiceBusClientBuilderFactory builderFactory = new ServiceBusClientBuilderFactory(this.serviceBusProperties);
builderFactory.setConnectionStringProvider(connectionStringProviders.getIfAvailable());
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS);
return builderFactory;
final ServiceBusClientBuilderFactory factory = new ServiceBusClientBuilderFactory(this.serviceBusProperties);
factory.setConnectionStringProvider(connectionStringProviders.getIfAvailable());
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS);
return factory;
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -69,7 +69,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForConsumer(

builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS,
this.consumerProperties.getConnectionString()));
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS);
return builderFactory;
}

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.condition.ConditionalOnMissingProperty;
import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import com.azure.spring.servicebus.core.ServiceBusMessageProcessor;
Expand Down Expand Up @@ -66,7 +66,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForProcessor
final ServiceBusClientBuilderFactory builderFactory = new ServiceBusClientBuilderFactory(this.processorProperties);
builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS,
this.processorProperties.getConnectionString()));
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS);

return builderFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
import com.azure.spring.cloud.autoconfigure.servicebus.properties.AzureServiceBusProperties;
import com.azure.spring.core.ApplicationId;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
import org.slf4j.Logger;
Expand Down Expand Up @@ -74,7 +74,7 @@ public ServiceBusClientBuilderFactory serviceBusClientBuilderFactoryForProducer(

builderFactory.setConnectionStringProvider(new StaticConnectionStringProvider<>(AzureServiceType.SERVICE_BUS,
this.producerProperties.getConnectionString()));
builderFactory.setSpringIdentifier(ApplicationId.AZURE_SPRING_SERVICE_BUS);
builderFactory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_SERVICE_BUS);

return builderFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.storage.blob.BlobAsyncClient;
import com.azure.storage.blob.BlobClient;
import com.azure.storage.blob.BlobContainerAsyncClient;
Expand Down Expand Up @@ -90,6 +91,7 @@ public BlobServiceClientBuilderFactory blobServiceClientBuilderFactory(AzureStor
@Bean
@ConditionalOnMissingBean
public BlobServiceClientBuilder blobServiceClientBuilder(BlobServiceClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_BLOB);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import java.util.List;
import java.util.function.BiConsumer;

import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_BLOB;
import static com.azure.spring.core.ApplicationId.VERSION;

/**
* Storage Blob Service client builder factory, it builds the storage blob client according the configuration context
* and blob properties.
Expand Down Expand Up @@ -102,8 +99,4 @@ protected List<AuthenticationDescriptor<?>> getAuthenticationDescriptors(BlobSer
);
}

@Override
protected String getApplicationId() {
return AZURE_SPRING_STORAGE_BLOB + VERSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.storage.file.share.ShareAsyncClient;
import com.azure.storage.file.share.ShareClient;
import com.azure.storage.file.share.ShareFileAsyncClient;
Expand Down Expand Up @@ -58,6 +59,7 @@ public ShareServiceClientBuilderFactory shareServiceClientBuilderFactory(AzureSt
@Bean
@ConditionalOnMissingBean
public ShareServiceClientBuilder shareServiceClientBuilder(ShareServiceClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_FILES);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import java.util.List;
import java.util.function.BiConsumer;

import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_FILES;
import static com.azure.spring.core.ApplicationId.VERSION;

/**
* Storage File Share Service client builder factory, it builds the storage blob client according the configuration
* context and blob properties.
Expand Down Expand Up @@ -101,8 +98,4 @@ protected BiConsumer<ShareServiceClientBuilder, String> consumeConnectionString(
return ShareServiceClientBuilder::connectionString;
}

@Override
protected String getApplicationId() {
return AZURE_SPRING_STORAGE_FILES + VERSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.spring.cloud.autoconfigure.AzureServiceConfigurationBase;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.properties.AzureGlobalProperties;
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.service.AzureServiceType;
Expand Down Expand Up @@ -61,6 +62,7 @@ public QueueServiceClientBuilderFactory queueServiceClientBuilderFactory(AzureSt
@Bean
@ConditionalOnMissingBean
public QueueServiceClientBuilder queueServiceClientBuilder(QueueServiceClientBuilderFactory factory) {
factory.setSpringIdentifier(AzureSpringIdentifier.AZURE_SPRING_STORAGE_QUEUE);
return factory.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import java.util.List;
import java.util.function.BiConsumer;

import static com.azure.spring.core.ApplicationId.AZURE_SPRING_STORAGE_QUEUE;
import static com.azure.spring.core.ApplicationId.VERSION;

/**
* Storage Queue Service client builder factory, it builds the storage blob client according the configuration context
* and blob properties.
Expand Down Expand Up @@ -99,11 +96,6 @@ protected BiConsumer<QueueServiceClientBuilder, String> consumeConnectionString(
return QueueServiceClientBuilder::connectionString;
}

@Override
protected String getApplicationId() {
return AZURE_SPRING_STORAGE_QUEUE + VERSION;
}

private QueueMessageEncoding convertToMessageEncoding(String messageEncoding) {
return QueueMessageEncoding.BASE64
.name()
Expand Down
Loading