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 all 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 com.azure.spring.service.appconfiguration.ConfigurationClientBuilderFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -49,6 +50,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 @@ -6,7 +6,7 @@
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
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 @@ -9,7 +9,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
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.service.core.PropertyMapper;
Expand Down Expand Up @@ -85,7 +85,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 @@ -9,7 +9,7 @@
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnMissingProperty;
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.service.eventhubs.factory.EventHubClientBuilderFactory;
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 @@ -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 @@ -50,6 +50,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 com.azure.spring.service.keyvault.secrets.SecretClientBuilderFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -50,6 +51,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 @@ -36,10 +36,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 com.azure.spring.service.servicebus.ServiceBusClientBuilderFactory;
Expand Down Expand Up @@ -70,7 +70,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.service.servicebus.ServiceBusClientBuilderFactory;
Expand Down Expand Up @@ -67,7 +67,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 com.azure.spring.service.servicebus.ServiceBusClientBuilderFactory;
Expand Down Expand Up @@ -75,7 +75,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.spring.service.storage.blob.BlobServiceClientBuilderFactory;
import com.azure.storage.blob.BlobAsyncClient;
import com.azure.storage.blob.BlobClient;
Expand Down Expand Up @@ -95,6 +96,7 @@ public BlobServiceClientBuilderFactory blobServiceClientBuilderFactory(AzureStor
@ConditionalOnMissingBean
public BlobServiceClientBuilder blobServiceClientBuilder(@Qualifier(STORAGE_BLOB_CLIENT_BUILDER_FACTORY_BEAN_NAME)
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 @@ -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.service.storage.fileshare.ShareServiceClientBuilderFactory;
import com.azure.storage.file.share.ShareAsyncClient;
import com.azure.storage.file.share.ShareClient;
Expand Down Expand Up @@ -59,6 +60,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 @@ -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 @@ -62,6 +63,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 @@ -12,9 +12,9 @@
import java.util.Properties;

/**
* Util class for ApplicationId
* Util class for AzureSpringIdentifier
*/
public class ApplicationId {
public class AzureSpringIdentifier {
// There is 24 char limitation about the app id. So some abbreviation needs to be applied:
// az: for Azure
// sp: for Spring
Expand All @@ -32,17 +32,17 @@ public class ApplicationId {
// cos: for Cosmos
// aad: for AAD
// b2c: for AAD B2C
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationId.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AzureSpringIdentifier.class);
public static final String VERSION = getVersion();
public static final String AZURE_SPRING_KEY_VAULT = "az-sp-kv/";
public static final String AZURE_SPRING_SERVICE_BUS = "az-sp-bus/";
public static final String AZURE_SPRING_STORAGE_BLOB = "az-sp-sb/";
public static final String AZURE_SPRING_STORAGE_FILES = "az-sp-sf/";

public static final String AZURE_SPRING_COSMOS = "az-sp-cosmos";
public static final String AZURE_SPRING_EVENT_HUB = "az-sc-eh/;";
public static final String AZURE_SPRING_STORAGE_QUEUE = "az-sp-sq/";
public static final String AZURE_SPRING_INTEGRATION_STORAGE_QUEUE = "az-si-sq/";
public static final String AZURE_SPRING_APP_CONFIG = "az-sp-cfg/" + VERSION;
public static final String AZURE_SPRING_EVENT_HUB = "az-sp-eh/" + VERSION;
public static final String AZURE_SPRING_KEY_VAULT = "az-sp-kv/" + VERSION;
public static final String AZURE_SPRING_SERVICE_BUS = "az-sp-bus/" + VERSION;
public static final String AZURE_SPRING_STORAGE_BLOB = "az-sp-sb/" + VERSION;
public static final String AZURE_SPRING_STORAGE_FILES = "az-sp-sf/" + VERSION;
public static final String AZURE_SPRING_COSMOS = "az-sp-cos/" + VERSION;
public static final String AZURE_SPRING_STORAGE_QUEUE = "az-sp-sq/" + VERSION;
public static final String AZURE_SPRING_INTEGRATION_STORAGE_QUEUE = "az-si-sq/" + VERSION;

/**
* AZURE_SPRING_AAD does not contain VERSION, because AAD server support 2 headers: 1. x-client-SKU; 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected void configureClientProperties(T builder) {
}

@Override
protected void configureApplicationId(T builder) {
this.clientOptions.setApplicationId(getApplicationId());
protected BiConsumer<T, String> consumeApplicationId() {
return (builder, id) -> this.clientOptions.setApplicationId(id);
}

@Override
Expand Down Expand Up @@ -96,6 +96,4 @@ public void setClientOptions(ClientOptions clientOptions) {
this.clientOptions = clientOptions;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ protected void configureProxy(T builder) {
}

@Override
protected void configureApplicationId(T builder) {
this.httpClientOptions.setApplicationId(getApplicationId());
protected BiConsumer<T, String> consumeApplicationId() {
return (builder, id) -> this.httpClientOptions.setApplicationId(id);
}

protected void configureHttpHeaders(T builder) {
Expand Down
Loading