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

Modify spring-cloud-azure-core, spring-cloud-azure-service, and spring-cloud-azure-resourcemanager according to API review comments #25851

Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9300379
complete javadocs
saragluna Dec 6, 2021
ecf63a5
Merge branch 'feature/azure-spring-cloud-4.0' into xiada/feature/spri…
saragluna Dec 6, 2021
b0e69d9
complete javadocs and remove some unused classes
saragluna Dec 6, 2021
b7d9605
change according to API review
saragluna Dec 7, 2021
c5d8025
make classes final by default
saragluna Dec 7, 2021
a76154b
add java docs
saragluna Dec 7, 2021
8801b81
fix compilation error
saragluna Dec 7, 2021
d5011ca
move some classes to implementation package
saragluna Dec 7, 2021
cae9c2b
add java docs
saragluna Dec 7, 2021
25cc0ce
add java docs
saragluna Dec 7, 2021
c273b37
remove unused implementation of service client builder customizer
saragluna Dec 13, 2021
952e4bd
Merge branch 'feature/azure-spring-cloud-4.0' into xiada/feature/spri…
saragluna Dec 13, 2021
fde849a
add opens for spring-cloud-azure-core tests
saragluna Dec 13, 2021
dc767ac
move all configuration proeprties implementation to the package imple…
saragluna Dec 13, 2021
d3c74bd
remove abstract from the properties class
saragluna Dec 13, 2021
957cdc5
remove module-info.java for surefire plugin doesn't work with require…
saragluna Dec 13, 2021
620397e
move all configuration proeprties implementation out of the package i…
saragluna Dec 13, 2021
3898a39
decouple the trace bean post processor with sleuth
saragluna Dec 13, 2021
864b414
address api review comments for spring-cloud-azure-service
saragluna Dec 14, 2021
9df1cfc
address api review comments for spring-cloud-azure-service
saragluna Dec 14, 2021
bed5917
address api review comments for spring-cloud-azure-resourcemanager
saragluna Dec 14, 2021
733a9ae
address api review comments for spring-cloud-azure-resourcemanager
saragluna Dec 14, 2021
2cc4982
Merge branch 'feature/azure-spring-cloud-4.0' into xiada/feature/spri…
saragluna Dec 14, 2021
ed89e66
add java docs
saragluna Dec 14, 2021
ec20e6e
remove the protected modifier
saragluna Dec 15, 2021
0db6d87
add module-info.java for spring-cloud-azure-core
saragluna Dec 16, 2021
9121aa0
add module-info.java for service and resourcemanager module
saragluna Dec 16, 2021
8f4764d
Merge branch 'feature/azure-spring-cloud-4.0' into xiada/feature/spri…
saragluna Dec 16, 2021
e83d686
complete module-info.java
saragluna Dec 20, 2021
78b3d12
update description for managed-identity-client-id
saragluna Dec 20, 2021
9f179fc
Merge branch 'feature/azure-spring-cloud-4.0' into xiada/feature/spri…
saragluna Dec 21, 2021
22dd0b7
resolve compilation errors after merge
saragluna Dec 21, 2021
371c73a
fix tests coverage
saragluna Dec 23, 2021
8ce59d5
adjust test coverage ratios
saragluna Dec 23, 2021
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 @@ -489,7 +489,6 @@ the main ServiceBusClientBuilder. -->
<!--BlacklistedWordsCheck: URL is the name -->
<suppress checks="com.azure.tools.checkstyle.checks.BlacklistedWordsCheck" files="com.azure.spring.core.resource.StorageBlobResource.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.BlacklistedWordsCheck" files="com.azure.spring.core.resource.StorageFileResource.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.BlacklistedWordsCheck" files="com.azure.spring.core.util.URLValidator.java"/>

<!-- EnforceFinalFieldsCheck: The property will be filled by Spring framework -->
<suppress checks="com.azure.tools.checkstyle.checks.EnforceFinalFieldsCheck" files="com.azure.spring.data.cosmos.config.AbstractCosmosConfiguration.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2277,10 +2277,10 @@
<Match>
<And>
<Or>
<Class name="com.azure.spring.core.credential.resolver.AzureKeyCredentialResolver"/>
<Class name="com.azure.spring.core.credential.resolver.AzureNamedKeyCredentialResolver"/>
<Class name="com.azure.spring.core.credential.resolver.AzureSasCredentialResolver"/>
<Class name="com.azure.spring.service.storage.common.credential.StorageSharedKeyCredentialResolver" />
<Class name="com.azure.spring.core.implementation.credential.resolver.AzureKeyCredentialResolver"/>
<Class name="com.azure.spring.core.implementation.credential.resolver.AzureNamedKeyCredentialResolver"/>
<Class name="com.azure.spring.core.implementation.credential.resolver.AzureSasCredentialResolver"/>
<Class name="com.azure.spring.service.implementation.storage.credential.StorageSharedKeyCredentialResolver" />
</Or>
<Method name="resolve"/>
</And>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.azure.spring.core.aware.ProxyAware;
import com.azure.spring.core.aware.RetryAware;
import com.azure.spring.core.properties.AzureProperties;
import com.azure.spring.core.properties.util.AzurePropertiesUtils;
import com.azure.spring.core.util.AzurePropertiesUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
Expand All @@ -26,6 +26,16 @@ public AzureServiceConfigurationBase(AzureGlobalProperties azureProperties) {
this.azureGlobalProperties = azureProperties;
}

/**
* Load the default value to an Azure Service properties from the global Azure properties.
*
* @param source The global Azure properties.
* @param target The properties of an Azure Service, such as Event Hubs properties. Some common components of the
* service's properties have default value as set to the global properties. For example, the proxy of
* the Event Hubs properties takes the proxy set to the global Azure properties as default.
* @param <T> The type of the properties of an Azure Service.
* @return The Azure Service's properties.
*/
protected <T extends AzureProperties> T loadProperties(AzureGlobalProperties source, T target) {
AzurePropertiesUtils.copyAzureCommonProperties(source, target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
package com.azure.spring.cloud.autoconfigure.aadb2c.properties;

import com.azure.spring.cloud.autoconfigure.aadb2c.implementation.AADB2CConfigurationException;
import com.azure.spring.core.util.URLValidator;
import com.nimbusds.jose.jwk.source.RemoteJWKSet;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -156,14 +156,31 @@ private void validateCommonProperties() {
* Validate URL properties configuration.
*/
private void validateURLProperties() {
if (!URLValidator.isValidURL(logoutSuccessUrl)) {
if (!isValidUrl(logoutSuccessUrl)) {
throw new AADB2CConfigurationException("logout success should be valid URL.");
}
if (!URLValidator.isValidURL(baseUri)) {
if (!isValidUrl(baseUri)) {
throw new AADB2CConfigurationException("baseUri should be valid URL.");
}
}

/**
* Used to validate uri, the uri is allowed to be empty.
* @param uri the uri to be validated.
* @return whether is uri is valid or not.
*/
private static boolean isValidUrl(String uri) {
if (!StringUtils.hasLength(uri)) {
return true;
}
try {
new java.net.URL(uri);
} catch (MalformedURLException var) {
return false;
}
return true;
}


/**
* Gets the password reset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.context.annotation.Bean;

/**
* Auto-configuration for a {@link ConfigurationClientBuilder} and Azure App Configuration clients.
* Autoconfiguration for a {@link ConfigurationClientBuilder} and Azure App Configuration clients.
*/
@ConditionalOnClass(ConfigurationClientBuilder.class)
@ConditionalOnProperty(value = "spring.cloud.azure.appconfiguration.enabled", havingValue = "true", matchIfMissing = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@
package com.azure.spring.cloud.autoconfigure.appconfiguration.properties;

import com.azure.data.appconfiguration.ConfigurationServiceVersion;
import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureHttpCP;
import com.azure.spring.service.appconfiguration.AppConfigurationProperties;
import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureHttpCP;
import com.azure.spring.service.appconfiguration.ConfigurationClientProperties;

/**
* Properties for Azure App Configuration.
*/
public class AzureAppConfigurationProperties extends AbstractAzureHttpCP
implements AppConfigurationProperties {
implements ConfigurationClientProperties {

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

/**
* Endpoint of the Azure App Configuration instance.
*/
private String endpoint;
/**
* Connection string of the Azure App Configuration instance.
*/
private String connectionString;
/**
* Version of the service to be used when making request.
*/
private ConfigurationServiceVersion serviceVersion;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
/**
* A prefix that should be applied to each property. The prefix automatically ends
* with a dot if not specified. A valid prefix is defined by one or more words
* separated with dots (e.g. {@code "azure.spring.cloud"}).
* separated with dots (e.g. {@code "spring.cloud.azure"}).
* @return the prefix
*/
String prefix() default "";

/**
* The name of the properties to test. If a prefix has been defined, it is applied to
* compute the full key of each property. For instance if the prefix is
* {@code azure.spring.cloud} and one value is {@code my-value}, the full key would be
* {@code azure.spring.cloud.my-value}
* compute the full key of each property. For instance if the prefix is {@code "spring.cloud.azure"}
* and one value is {@code "my-value"}, the full key would be
* {@code "spring.cloud.azure.my-value"}
* <p>
* Use the dashed notation to specify each property, that is all lower case with a "-"
* to separate words (e.g. {@code my-long-property}).
* to separate words (e.g. {@code "my-long-property"}).
* @return the names
*/
String[] name() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
/**
* A prefix that should be applied to each property. The prefix automatically ends
* with a dot if not specified. A valid prefix is defined by one or more words
* separated with dots (e.g. {@code "azure.spring.cloud"}).
* separated with dots (e.g. {@code "spring.cloud.azure"}).
* @return the prefix
*/
String prefix() default "";

/**
* The name of the properties to test. If a prefix has been defined, it is applied to
* compute the full key of each property. For instance if the prefix is
* {@code azure.spring.cloud} and one value is {@code my-value}, the full key would be
* {@code azure.spring.cloud.my-value}
* {@code "spring.cloud.azure"} and one value is {@code "my-value"}, the full key would be
* {@code "spring.cloud.azure.my-value"}
* <p>
* Use the dashed notation to specify each property, that is all lower case with a "-"
* to separate words (e.g. {@code my-long-property}).
* to separate words (e.g. {@code "my-long-property"}).
* @return the names
*/
String[] name() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureServiceCP;
import com.azure.spring.cloud.autoconfigure.properties.core.client.ClientCP;
import com.azure.spring.cloud.autoconfigure.properties.core.proxy.HttpProxyCP;
import com.azure.spring.service.cosmos.CosmosProperties;
import com.azure.spring.service.cosmos.CosmosClientProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.ArrayList;
Expand All @@ -21,7 +21,7 @@
/**
* Configuration properties for Cosmos database, consistency, telemetry, connection, query metrics and diagnostics.
*/
public class AzureCosmosProperties extends AbstractAzureServiceCP implements CosmosProperties {
public class AzureCosmosProperties extends AbstractAzureServiceCP implements CosmosClientProperties {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.time.Duration;

import static com.azure.spring.cloud.autoconfigure.context.AzureContextUtils.EVENT_HUB_PROCESSOR_CHECKPOINT_STORE_STORAGE_CLIENT_BUILDER_FACTORY_BEAN_NAME;
import static com.azure.spring.core.properties.util.AzurePropertiesUtils.mergeAzureCommonProperties;
import static com.azure.spring.core.util.AzurePropertiesUtils.mergeAzureCommonProperties;

/**
* Configures a {@link BlobCheckpointStore}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import com.azure.spring.core.AzureSpringIdentifier;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.customizer.AzureServiceClientBuilderCustomizer;
import com.azure.spring.core.properties.util.PropertyMapper;
import com.azure.spring.core.service.AzureServiceType;
import com.azure.spring.service.eventhubs.factory.EventHubClientBuilderFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand Down Expand Up @@ -51,7 +51,7 @@ static class SharedConsumerConnectionConfiguration {
SharedConsumerConnectionConfiguration(AzureEventHubsProperties properties, EventHubClientBuilder builder) {
this.builder = builder;

PropertyMapper mapper = new PropertyMapper();
PropertyMapper mapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
mapper.from(properties.getConsumer().getConsumerGroup()).to(builder::consumerGroup);
mapper.from(properties.getConsumer().getPrefetchCount()).to(builder::prefetchCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.azure.messaging.eventhubs.CheckpointStore;
import com.azure.spring.cloud.autoconfigure.condition.ConditionalOnAnyProperty;
import com.azure.spring.cloud.autoconfigure.eventhubs.properties.AzureEventHubsProperties;
import com.azure.spring.core.properties.util.AzurePropertiesUtils;
import com.azure.spring.core.util.AzurePropertiesUtils;
import com.azure.spring.eventhubs.core.EventHubsProcessorContainer;
import com.azure.spring.eventhubs.core.EventHubsTemplate;
import com.azure.spring.eventhubs.core.processor.DefaultEventHubsNamespaceProcessorFactory;
Expand All @@ -29,7 +29,7 @@
import org.springframework.context.annotation.Import;
import reactor.util.function.Tuple2;

import static com.azure.spring.core.properties.util.AzurePropertiesUtils.copyAzureCommonProperties;
import static com.azure.spring.core.util.AzurePropertiesUtils.copyAzureCommonProperties;

/**
* An auto-configuration for Event Hub, which provides {@link EventHubsTemplate} and {@link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.azure.spring.cloud.autoconfigure.resourcemanager.AzureEventHubsResourceManagerAutoConfiguration;
import com.azure.spring.core.connectionstring.ConnectionStringProvider;
import com.azure.spring.core.connectionstring.StaticConnectionStringProvider;
import com.azure.spring.core.connectionstring.implementation.EventHubsConnectionString;
import com.azure.spring.core.implementation.connectionstring.EventHubsConnectionString;
import com.azure.spring.core.service.AzureServiceType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

package com.azure.spring.cloud.autoconfigure.eventhubs.properties;

import com.azure.spring.cloud.autoconfigure.properties.AbstractAzureAmqpCP;
import com.azure.spring.core.connectionstring.implementation.EventHubsConnectionString;
import com.azure.spring.cloud.autoconfigure.properties.core.AbstractAzureAmqpCP;
import com.azure.spring.core.implementation.connectionstring.EventHubsConnectionString;

/**
* Azure Event Hubs related properties.
Expand Down Expand Up @@ -36,7 +36,7 @@ protected String extractEventHubNameFromConnectionString() {
// servicebus.windows.net)
// Endpoint=sb://<FQDN>/;SharedAccessKeyName=<KeyName>;SharedAccessKey=<KeyValue>
// https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string
public String getFQDN() {
public String getFullyQualifiedNamespace() {
return this.namespace == null ? extractFqdnFromConnectionString() : (this.namespace + "." + domainName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
package com.azure.spring.cloud.autoconfigure.eventhubs.properties;

import com.azure.spring.cloud.autoconfigure.storage.blob.properties.AzureStorageBlobProperties;
import com.azure.spring.core.properties.util.AzurePropertiesUtils;
import com.azure.spring.service.eventhubs.properties.EventHubsConsumerDescriptor;
import com.azure.spring.service.eventhubs.properties.EventHubsNamespaceDescriptor;
import com.azure.spring.service.eventhubs.properties.EventHubsProcessorDescriptor;
import com.azure.spring.service.eventhubs.properties.EventHubsProducerDescriptor;
import com.azure.spring.core.util.AzurePropertiesUtils;
import com.azure.spring.service.eventhubs.properties.EventHubConsumerProperties;
import com.azure.spring.service.eventhubs.properties.EventHubProducerProperties;
import com.azure.spring.service.eventhubs.properties.EventHubsNamespaceProperties;
import com.azure.spring.service.eventhubs.properties.EventProcessorClientProperties;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.context.properties.PropertyMapper;

Expand All @@ -19,7 +19,7 @@
/**
* Azure Event Hubs related properties.
*/
public class AzureEventHubsProperties extends AzureEventHubsCommonProperties implements EventHubsNamespaceDescriptor {
public class AzureEventHubsProperties extends AzureEventHubsCommonProperties implements EventHubsNamespaceProperties {

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

Expand Down Expand Up @@ -129,14 +129,14 @@ public Processor getProcessor() {
/**
* Properties of an Event Hub producer.
*/
public static class Producer extends AzureEventHubsCommonProperties implements EventHubsProducerDescriptor {
public static class Producer extends AzureEventHubsCommonProperties implements EventHubProducerProperties {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need we rename EventHubsProducerDescriptor to EventHubProducerClientProperties?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given Event Hubs only have one client builder, EventHubClientBuilder, so we won't call it EventHubProducerClientProperties.


}

/**
* Properties of an Event Hub consumer.
*/
public static class Consumer extends AzureEventHubsCommonProperties implements EventHubsConsumerDescriptor {
public static class Consumer extends AzureEventHubsCommonProperties implements EventHubConsumerProperties {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need we rename EventHubsConsumerDescriptor to EventHubConsumerClientProperties?


/**
* Name of the consumer group this consumer is associated with.
Expand Down Expand Up @@ -170,12 +170,12 @@ public void setPrefetchCount(Integer prefetchCount) {
/**
* Properties of an Event Hub processor.
*/
public static class Processor extends Consumer implements EventHubsProcessorDescriptor {
public static class Processor extends Consumer implements EventProcessorClientProperties {

private Boolean trackLastEnqueuedEventProperties;
private Map<String, StartPosition> initialPartitionEventPosition = new HashMap<>();
private Duration partitionOwnershipExpirationInterval;
private final Batch batch = new Batch();
private final EventBatch batch = new EventBatch();
private final LoadBalancing loadBalancing = new LoadBalancing();
private final BlobCheckpointStore checkpointStore = new BlobCheckpointStore();

Expand Down Expand Up @@ -203,7 +203,7 @@ public void setPartitionOwnershipExpirationInterval(Duration partitionOwnershipE
this.partitionOwnershipExpirationInterval = partitionOwnershipExpirationInterval;
}

public Batch getBatch() {
public EventBatch getBatch() {
return batch;
}

Expand All @@ -218,21 +218,21 @@ public BlobCheckpointStore getCheckpointStore() {
/**
* Event processor load balancing properties.
*/
public static class LoadBalancing extends EventHubsProcessorDescriptor.LoadBalancing {
public static class LoadBalancing extends EventProcessorClientProperties.LoadBalancing {

}

/**
* Event processor batch properties.
*/
public static class Batch extends EventHubsProcessorDescriptor.Batch {
public static class EventBatch extends EventProcessorClientProperties.EventBatch {

}

/**
* Blob checkpoint store.
*/
public static class BlobCheckpointStore extends AzureStorageBlobProperties {
public static class BlobCheckpointStore extends AzureStorageBlobProperties {

private Boolean createContainerIfNotExists;

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

import com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties;
import com.azure.spring.core.connectionstring.implementation.ServiceBusConnectionString;
import com.azure.spring.core.implementation.connectionstring.ServiceBusConnectionString;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand Down
Loading