public abstract class NacosUtil extends Object implements NacosBeanConstants
| 限定符和类型 | 字段和说明 |
|---|---|
static boolean |
DEFAULT_BOOLEAN_ATTRIBUTE_VALUE
Default value of boolean attribute for
Annotation |
static String |
DEFAULT_CONFIG_TYPE_VALUE
Default value of
String attribute for Annotation |
static String |
DEFAULT_STRING_ATTRIBUTE_VALUE
Default value of
String attribute for Annotation |
static long |
DEFAULT_TIMEOUT
Default timeout for getting Nacos configuration
|
private static org.slf4j.Logger |
logger |
private static Set<Class<?>> |
NON_BEAN_CLASSES |
private static Boolean |
readTypeFromDataId |
static String |
SEPARATOR
The separator
|
CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, DISCOVERY_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, GLOBAL_NACOS_PROPERTIES_BEAN_NAME, IGNORE_RESOURCE_NOT_FOUND, IGNORE_UNRESOLVABLE_PLACEHOLDERS, MAINTAIN_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, NACOS_CONFIG_LISTENER_EXECUTOR_BEAN_NAME, PLACEHOLDER_CONFIGURER_BEAN_NAME| 限定符 | 构造器和说明 |
|---|---|
private |
NacosUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
private static void |
bindBean(String propertyName,
Class<?> target,
Map<String,Object> configProperties,
org.springframework.beans.MutablePropertyValues propertyValues)
bind properties to bean
|
private static void |
bindContainer(String prefix,
String fieldName,
Map<String,Object> configProperties,
org.springframework.beans.MutablePropertyValues propertyValues)
Simple solutions to support
Map or Collection |
private static String |
build(Object... values) |
static String |
buildDefaultPropertySourceName(String dataId,
String groupId,
Map<?,?> properties)
Build The default name of
@NacosPropertySource |
private static ExecutorService |
buildNacosConfigListenerExecutor(org.springframework.core.env.Environment environment) |
static void |
cleanMapOrCollectionField(Object bean) |
private static boolean |
containsDescendantOf(Set<String> names,
String propertyName) |
static Map<Object,Object> |
extractSafeProperties(Properties properties) |
static ConfigServiceBeanBuilder |
getConfigServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory)
Get
ConfigServiceBeanBuilder Bean |
static String |
getContent(com.alibaba.nacos.api.config.ConfigService configService,
String dataId,
String groupId)
Get content from
ConfigService via dataId and groupId |
static Properties |
getGlobalPropertiesBean(org.springframework.beans.factory.BeanFactory beanFactory)
Get Global Properties Bean
|
static ExecutorService |
getNacosConfigListenerExecutorIfPresent(org.springframework.beans.factory.BeanFactory beanFactory)
Get
Executor Bean for Nacos Config Listener If Present |
static NacosServiceFactory |
getNacosServiceFactoryBean() |
static NacosServiceFactory |
getNacosServiceFactoryBean(org.springframework.beans.factory.BeanFactory beanFactory)
Get
NacosServiceFactory Bean |
static NamingMaintainServiceBeanBuilder |
getNamingMaintainServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory)
Get
NamingMaintainServiceBeanBuilder Bean |
static NamingServiceBeanBuilder |
getNamingServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory)
Get
NamingServiceBeanBuilder Bean |
private static int |
getParallelism(org.springframework.core.env.Environment environment) |
static String |
identify(Map<?,?> properties)
Generate Id of
Nacos Properties |
static String |
identify(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties)
Generate Id of
Nacos Properties annotation |
static void |
invokeNacosPropertySourcePostProcessor(org.springframework.beans.factory.BeanFactory beanFactory)
Invokes
NacosPropertySourcePostProcessor |
static boolean |
isBeanDefinitionPresent(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> targetBeanClass)
Is
BeanDefinition present in BeanDefinitionRegistry |
static boolean |
isDefault(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties)
Is
@NacosProperties with default attribute values. |
static Boolean |
isReadTypeFromDataId() |
private static boolean |
isUnbindableBean(Class<?> resolved) |
private static Map<String,Object> |
listToProperties(String fieldName,
String content)
convert list=1,2,3,4 to list[0]=1, list[1]=2, list[2]=3, list[3]=4
|
protected static void |
merge(Properties targetProperties,
Properties sourceProperties)
Merge Nacos Properties If any property from target properties is absent
|
static String |
readFileExtension(String dataId) |
static String |
readFromEnvironment(String label,
org.springframework.core.env.Environment environment) |
private static void |
registerAnnotationNacosInjectedBeanPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
NacosNamingRegisterInfo
AnnotationNacosInjectedBeanPostProcessor with
name |
static void |
registerAnnotationNacosPropertySourceBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
private static void |
registerConfigServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerGlobalNacosProperties(org.springframework.core.annotation.AnnotationAttributes attributes,
org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.PropertyResolver propertyResolver,
String beanName)
NacosNamingRegisterInfo Global Nacos Properties Bean with specified name
|
static void |
registerGlobalNacosProperties(Map<?,?> globalPropertiesAttributes,
org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.PropertyResolver propertyResolver,
String beanName)
NacosNamingRegisterInfo Global Nacos Properties Bean with specified name
|
static void |
registerInfrastructureBean(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> beanClass,
Object... constructorArgs)
NacosNamingRegisterInfo Infrastructure Bean
|
static void |
registerInfrastructureBeanIfAbsent(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> beanClass,
Object... constructorArgs)
NacosNamingRegisterInfo Infrastructure Bean if absent
|
private static void |
registerLoggingNacosConfigMetadataEventListener(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
NacosNamingRegisterInfo
LoggingNacosConfigMetadataEventListener Bean |
static void |
registerNacosApplicationContextHolder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerNacosCommonBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
NacosNamingRegisterInfo Nacos Common Beans
|
static void |
registerNacosConfigBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.Environment environment,
org.springframework.beans.factory.BeanFactory beanFactory)
NacosNamingRegisterInfo Nacos Config Beans
|
static void |
registerNacosConfigListenerExecutor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.Environment environment) |
static void |
registerNacosConfigListenerMethodProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerNacosConfigPropertiesBindingPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerNacosDiscoveryBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
NacosNamingRegisterInfo Nacos Discovery Beans
|
static void |
registerNacosPropertySourcePostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerNacosValueAnnotationBeanPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
private static void |
registerNamingMaintainServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
private static void |
registerNamingServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
registerPropertySourcesPlaceholderConfigurer(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.beans.factory.BeanFactory beanFactory)
NacosNamingRegisterInfo
PropertySourcesPlaceholderConfigurer Bean |
static void |
registerSingleton(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Object singletonObject)
NacosNamingRegisterInfo an object to be Singleton Bean
|
static void |
registerXmlNacosPropertySourceBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) |
static void |
resetReadTypeFromDataId() |
static org.springframework.beans.factory.BeanFactory |
resolveBeanFactory(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
Resolve
BeanFactory from BeanDefinitionRegistry |
static <T> Class<T> |
resolveGenericType(Class<?> declaredClass) |
static Properties |
resolveProperties(Map<?,?> properties,
org.springframework.core.env.PropertyResolver propertyResolver)
Resolve placeholders of properties via specified
PropertyResolver if present |
static Properties |
resolveProperties(Map<String,Object> attributes,
org.springframework.core.env.PropertyResolver propertyResolver,
Properties defaultProperties)
|
static Properties |
resolveProperties(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties,
org.springframework.core.env.PropertyResolver propertyResolver) |
static Properties |
resolveProperties(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties,
org.springframework.core.env.PropertyResolver propertyResolver,
Properties defaultProperties) |
private static String |
resolvePropertyName(Field field) |
static org.springframework.beans.PropertyValues |
resolvePropertyValues(Object bean,
String content,
String type) |
static org.springframework.beans.PropertyValues |
resolvePropertyValues(Object bean,
String prefix,
String dataId,
String groupId,
String content,
String type) |
static void |
setReadTypeFromDataIdIfNull(boolean readTypeFromDataId) |
static Map<String,Object> |
toProperties(String text) |
static Map<String,Object> |
toProperties(String text,
String type) |
static Map<String,Object> |
toProperties(String dataId,
String group,
String text) |
static Map<String,Object> |
toProperties(String dataId,
String group,
String text,
String type)
XML configuration parsing to support different schemas
|
private static final org.slf4j.Logger logger
public static final String DEFAULT_STRING_ATTRIBUTE_VALUE
String attribute for Annotationpublic static final String DEFAULT_CONFIG_TYPE_VALUE
String attribute for Annotationpublic static final boolean DEFAULT_BOOLEAN_ATTRIBUTE_VALUE
Annotationpublic static final long DEFAULT_TIMEOUT
private static Boolean readTypeFromDataId
public static Boolean isReadTypeFromDataId()
public static void setReadTypeFromDataIdIfNull(boolean readTypeFromDataId)
public static void resetReadTypeFromDataId()
public static String buildDefaultPropertySourceName(String dataId, String groupId, Map<?,?> properties)
@NacosPropertySourcedataId - data IdgroupId - group Idproperties - Nacos Propertiespublic static String identify(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties)
Nacos Properties annotationnacosProperties - Nacos Properties annotationpublic static String identify(Map<?,?> properties)
Nacos Propertiesproperties - Nacos Propertiespublic static boolean isDefault(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties)
@NacosProperties with default attribute values.nacosProperties - @NacosPropertiestrue,or falsepublic static String readFromEnvironment(String label, org.springframework.core.env.Environment environment)
public static org.springframework.beans.PropertyValues resolvePropertyValues(Object bean, String content, String type)
public static org.springframework.beans.PropertyValues resolvePropertyValues(Object bean, String prefix, String dataId, String groupId, String content, String type)
public static Properties resolveProperties(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties, org.springframework.core.env.PropertyResolver propertyResolver)
public static Properties resolveProperties(com.alibaba.nacos.api.annotation.NacosProperties nacosProperties, org.springframework.core.env.PropertyResolver propertyResolver, Properties defaultProperties)
public static Properties resolveProperties(Map<String,Object> attributes, org.springframework.core.env.PropertyResolver propertyResolver, Properties defaultProperties)
Resolve placeholders of
@NacosProperties's attributes via specified PropertyResolver if present, or try
to merge from default propertiesattributes - @NacosProperties's attributespropertyResolver - the resolver of properties' placeholderdefaultProperties - default propertiesProperties propertiesresolveProperties(Map, PropertyResolver)public static Properties resolveProperties(Map<?,?> properties, org.springframework.core.env.PropertyResolver propertyResolver)
PropertyResolver if presentproperties - The propertiespropertyResolver - PropertyResolver instance, for instance, EnvironmentProperties after resolving.protected static void merge(Properties targetProperties, Properties sourceProperties)
targetProperties - target PropertiessourceProperties - source Propertiespublic static String getContent(com.alibaba.nacos.api.config.ConfigService configService, String dataId, String groupId)
ConfigService via dataId and groupIdconfigService - ConfigServicedataId - dataIdgroupId - groupIdnullprivate static void bindBean(String propertyName, Class<?> target, Map<String,Object> configProperties, org.springframework.beans.MutablePropertyValues propertyValues)
propertyName - propertyNametarget - bind targetconfigProperties - config contextpropertyValues - MutablePropertyValuesprivate static boolean containsDescendantOf(Set<String> names, String propertyName)
private static boolean isUnbindableBean(Class<?> resolved)
private static void bindContainer(String prefix, String fieldName, Map<String,Object> configProperties, org.springframework.beans.MutablePropertyValues propertyValues)
Map or Collectionprefix - prefixfieldName - property nameconfigProperties - config contextpropertyValues - MutablePropertyValuesprivate static Map<String,Object> listToProperties(String fieldName, String content)
fieldName - fieldNamecontent - contentPropertiespublic static Map<String,Object> toProperties(String dataId, String group, String text)
public static Map<String,Object> toProperties(String dataId, String group, String text, String type)
dataId - config dataIdgroup - config grouptext - config contexttype - config typepublic static void cleanMapOrCollectionField(Object bean)
public static void registerSingleton(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Object singletonObject)
registry - BeanDefinitionRegistrybeanName - bean namesingletonObject - singleton objectpublic static void registerInfrastructureBean(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> beanClass,
Object... constructorArgs)
registry - BeanDefinitionRegistrybeanName - the name of beanbeanClass - the class of beanconstructorArgs - the arguments of Constructorpublic static void registerInfrastructureBeanIfAbsent(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> beanClass,
Object... constructorArgs)
registry - BeanDefinitionRegistrybeanName - the name of beanbeanClass - the class of beanconstructorArgs - the arguments of Constructorpublic static org.springframework.beans.factory.BeanFactory resolveBeanFactory(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
BeanFactory from BeanDefinitionRegistryregistry - BeanDefinitionRegistryBeanFactory if resolvedpublic static boolean isBeanDefinitionPresent(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
String beanName,
Class<?> targetBeanClass)
BeanDefinition present in BeanDefinitionRegistryregistry - BeanDefinitionRegistrybeanName - the name of beantargetBeanClass - the type of beantruepublic static void registerPropertySourcesPlaceholderConfigurer(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.beans.factory.BeanFactory beanFactory)
PropertySourcesPlaceholderConfigurer Beanregistry - BeanDefinitionRegistrybeanFactory - BeanFactorypublic static void registerGlobalNacosProperties(org.springframework.core.annotation.AnnotationAttributes attributes,
org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.PropertyResolver propertyResolver,
String beanName)
attributes - the attributes of Global Nacos Properties may contain placeholdersregistry - BeanDefinitionRegistrypropertyResolver - PropertyResolverbeanName - Bean namepublic static void registerGlobalNacosProperties(Map<?,?> globalPropertiesAttributes, org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.core.env.PropertyResolver propertyResolver, String beanName)
globalPropertiesAttributes - the attributes of Global Nacos Properties may contain placeholdersregistry - BeanDefinitionRegistrypropertyResolver - PropertyResolverbeanName - Bean namepublic static void registerNacosApplicationContextHolder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerNacosConfigPropertiesBindingPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerNacosConfigListenerMethodProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerNacosPropertySourcePostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerAnnotationNacosPropertySourceBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerXmlNacosPropertySourceBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerNacosConfigListenerExecutor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.Environment environment)
private static ExecutorService buildNacosConfigListenerExecutor(org.springframework.core.env.Environment environment)
private static int getParallelism(org.springframework.core.env.Environment environment)
public static void registerNacosValueAnnotationBeanPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static void registerNacosCommonBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
registry - BeanDefinitionRegistrypublic static void registerNacosConfigBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry,
org.springframework.core.env.Environment environment,
org.springframework.beans.factory.BeanFactory beanFactory)
registry - BeanDefinitionRegistryenvironment - EnvironmentbeanFactory - BeanFactorypublic static void invokeNacosPropertySourcePostProcessor(org.springframework.beans.factory.BeanFactory beanFactory)
NacosPropertySourcePostProcessorbeanFactory - BeanFactoryprivate static void registerLoggingNacosConfigMetadataEventListener(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
LoggingNacosConfigMetadataEventListener Beanregistry - BeanDefinitionRegistrypublic static void registerNacosDiscoveryBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
registry - BeanDefinitionRegistryprivate static void registerAnnotationNacosInjectedBeanPostProcessor(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
AnnotationNacosInjectedBeanPostProcessor with
nameregistry - BeanDefinitionRegistryprivate static void registerConfigServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
private static void registerNamingServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
private static void registerNamingMaintainServiceBeanBuilder(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)
public static Properties getGlobalPropertiesBean(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
beanFactory - BeanFactoryorg.springframework.beans.factory.NoSuchBeanDefinitionException - if there is no such bean definitionpublic static NacosServiceFactory getNacosServiceFactoryBean(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
NacosServiceFactory BeanbeanFactory - BeanFactoryNacosServiceFactory Beanorg.springframework.beans.factory.NoSuchBeanDefinitionException - if there is no such bean definitionpublic static NacosServiceFactory getNacosServiceFactoryBean() throws org.springframework.beans.factory.NoSuchBeanDefinitionException
org.springframework.beans.factory.NoSuchBeanDefinitionExceptionpublic static ExecutorService getNacosConfigListenerExecutorIfPresent(org.springframework.beans.factory.BeanFactory beanFactory)
Executor Bean for Nacos Config Listener If PresentbeanFactory - BeanFactoryExecutor Bean If Present, or nullpublic static ConfigServiceBeanBuilder getConfigServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
ConfigServiceBeanBuilder BeanbeanFactory - BeanFactoryConfigServiceBeanBuilder Beanorg.springframework.beans.factory.NoSuchBeanDefinitionException - if there is no such bean definitionpublic static NamingServiceBeanBuilder getNamingServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
NamingServiceBeanBuilder BeanbeanFactory - BeanFactoryNamingServiceBeanBuilder Beanorg.springframework.beans.factory.NoSuchBeanDefinitionException - if there is no such bean definitionpublic static NamingMaintainServiceBeanBuilder getNamingMaintainServiceBeanBuilder(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
NamingMaintainServiceBeanBuilder BeanbeanFactory - BeanFactoryNamingMaintainServiceBeanBuilder Beanorg.springframework.beans.factory.NoSuchBeanDefinitionException - if there is no such bean definitionpublic static Map<Object,Object> extractSafeProperties(Properties properties)
Copyright © 2021 Zodiac. All rights reserved.