-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix warn logs in BeanPostProcessorChecker (#43096)
- Loading branch information
Showing
17 changed files
with
265 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...d/autoconfigure/implementation/context/AzureServiceClientBuilderFactoryConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.cloud.autoconfigure.implementation.context; | ||
|
||
import com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory; | ||
import org.springframework.beans.factory.config.BeanDefinition; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Role; | ||
|
||
/** | ||
* {@code @Configuration} class that registers a {@link AzureServiceClientBuilderFactoryPostProcessor} | ||
* bean capable of processing the {@link AbstractAzureServiceClientBuilderFactory } bean. | ||
* | ||
* @since 5.19.0 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
class AzureServiceClientBuilderFactoryConfiguration { | ||
|
||
/** | ||
* The BeanPostProcessor to apply the default token credential and resolver to all service client builder factories. | ||
* @return the BPP. | ||
*/ | ||
@Bean | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
static AzureServiceClientBuilderFactoryPostProcessor builderFactoryBeanPostProcessor() { | ||
return new AzureServiceClientBuilderFactoryPostProcessor(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...d/autoconfigure/implementation/context/AzureServiceClientBuilderFactoryPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.cloud.autoconfigure.implementation.context; | ||
|
||
import com.azure.core.credential.TokenCredential; | ||
import com.azure.spring.cloud.core.implementation.credential.resolver.AzureTokenCredentialResolver; | ||
import com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory; | ||
import com.azure.spring.cloud.core.implementation.factory.credential.AbstractAzureCredentialBuilderFactory; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.BeanFactory; | ||
import org.springframework.beans.factory.BeanFactoryAware; | ||
import org.springframework.beans.factory.config.BeanPostProcessor; | ||
|
||
import static com.azure.spring.cloud.autoconfigure.implementation.context.AzureContextUtils.DEFAULT_TOKEN_CREDENTIAL_BEAN_NAME; | ||
|
||
/** | ||
* {@link BeanPostProcessor} for {@link AbstractAzureServiceClientBuilderFactory} to configure default credential and resolver. | ||
*/ | ||
class AzureServiceClientBuilderFactoryPostProcessor implements BeanPostProcessor, BeanFactoryAware { | ||
|
||
private BeanFactory beanFactory; | ||
|
||
@Override | ||
@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { | ||
if (bean instanceof AbstractAzureCredentialBuilderFactory) { | ||
return bean; | ||
} | ||
|
||
if (bean instanceof AbstractAzureServiceClientBuilderFactory | ||
&& beanFactory.containsBean(DEFAULT_TOKEN_CREDENTIAL_BEAN_NAME)) { | ||
AbstractAzureServiceClientBuilderFactory factory = (AbstractAzureServiceClientBuilderFactory) bean; | ||
factory.setDefaultTokenCredential( | ||
(TokenCredential) beanFactory.getBean(DEFAULT_TOKEN_CREDENTIAL_BEAN_NAME)); | ||
factory.setTokenCredentialResolver(beanFactory.getBean(AzureTokenCredentialResolver.class)); | ||
} | ||
return bean; | ||
} | ||
|
||
@Override | ||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { | ||
this.beanFactory = beanFactory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ring/cloud/autoconfigure/implementation/eventhubs/kafka/KafkaPropertiesConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.cloud.autoconfigure.implementation.eventhubs.kafka; | ||
|
||
import com.azure.spring.cloud.autoconfigure.implementation.kafka.AzureEventHubsKafkaOAuth2AutoConfiguration; | ||
import com.azure.spring.cloud.core.provider.connectionstring.ServiceConnectionStringProvider; | ||
import com.azure.spring.cloud.core.service.AzureServiceType; | ||
import org.springframework.beans.factory.config.BeanDefinition; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.kafka.KafkaProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Role; | ||
|
||
/** | ||
* {@code @Configuration} class that registers a {@link KafkaPropertiesBeanPostProcessor} | ||
* bean capable of processing Kafka properties @{@link KafkaProperties}. | ||
* | ||
* @since 5.19.0 | ||
* @deprecated 4.3.0 in favor of {@link AzureEventHubsKafkaOAuth2AutoConfiguration}. | ||
*/ | ||
@Deprecated | ||
@Configuration(proxyBeanMethods = false) | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
class KafkaPropertiesConfiguration { | ||
|
||
@Bean | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
@ConditionalOnBean(value = AzureServiceType.EventHubs.class, parameterizedContainer = ServiceConnectionStringProvider.class) | ||
static KafkaPropertiesBeanPostProcessor kafkaPropertiesBeanPostProcessor( | ||
ServiceConnectionStringProvider<AzureServiceType.EventHubs> connectionStringProvider) { | ||
return new KafkaPropertiesBeanPostProcessor(connectionStringProvider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...e/spring/cloud/autoconfigure/implementation/jms/ServiceBusJmsPropertiesConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.cloud.autoconfigure.implementation.jms; | ||
|
||
import com.azure.spring.cloud.autoconfigure.implementation.condition.ConditionalOnMissingProperty; | ||
import com.azure.spring.cloud.autoconfigure.implementation.jms.properties.AzureServiceBusJmsProperties; | ||
import com.azure.spring.cloud.core.provider.connectionstring.ServiceConnectionStringProvider; | ||
import com.azure.spring.cloud.core.service.AzureServiceType; | ||
import org.springframework.beans.factory.ObjectProvider; | ||
import org.springframework.beans.factory.config.BeanDefinition; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Role; | ||
|
||
/** | ||
* {@code @Configuration} class that registers a {@link AzureServiceBusJmsPropertiesBeanPostProcessor} | ||
* bean capable of processing Service Bus JMS properties @{@link AzureServiceBusJmsProperties}. | ||
* | ||
* @since 5.19.0 | ||
*/ | ||
@Configuration(proxyBeanMethods = false) | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
class ServiceBusJmsPropertiesConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE) | ||
@ConditionalOnMissingProperty(prefix = "spring.jms.servicebus", name = "connection-string") | ||
static AzureServiceBusJmsPropertiesBeanPostProcessor azureServiceBusJmsPropertiesBeanPostProcessor( | ||
ObjectProvider<ServiceConnectionStringProvider<AzureServiceType.ServiceBus>> connectionStringProviders) { | ||
return new AzureServiceBusJmsPropertiesBeanPostProcessor(connectionStringProviders); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.