From fbe21a3b4d549e28bc9cdad1bcafb86474bd80dd Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Mon, 6 Jan 2025 10:11:20 +0800 Subject: [PATCH 1/4] Update BeanFactoryUtils.java --- .../spring/beans/factory/BeanFactoryUtils.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/BeanFactoryUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/BeanFactoryUtils.java index db6690d7..2a18de4b 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/BeanFactoryUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/BeanFactoryUtils.java @@ -16,6 +16,7 @@ */ package io.microsphere.spring.beans.factory; +import io.microsphere.util.ArrayUtils; import io.microsphere.util.BaseUtils; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.HierarchicalBeanFactory; @@ -37,6 +38,7 @@ import static io.microsphere.reflect.FieldUtils.getFieldValue; import static io.microsphere.util.ArrayUtils.of; +import static io.microsphere.util.ArrayUtils.size; import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.unmodifiableList; @@ -65,7 +67,6 @@ public abstract class BeanFactoryUtils extends BaseUtils { * @return A bean if present , or null */ public static T getOptionalBean(ListableBeanFactory beanFactory, String beanName, Class beanType) { - if (!hasText(beanName)) { return null; } @@ -88,21 +89,19 @@ public static T getOptionalBean(ListableBeanFactory beanFactory, String bean * @return the read-only and non-null {@link List} of Bean names */ public static List getBeans(ListableBeanFactory beanFactory, String[] beanNames, Class beanType) { - - if (isEmpty(beanNames)) { + int size = size(beanNames); + if (size < 1) { return emptyList(); } String[] allBeanNames = beanNamesForTypeIncludingAncestors(beanFactory, beanType, true, false); - - List beans = new ArrayList(beanNames.length); - - for (String beanName : beanNames) { + List beans = new ArrayList(size); + for (int i = 0; i < size; i++) { + String beanName = beanNames[i]; if (containsElement(allBeanNames, beanName)) { beans.add(beanFactory.getBean(beanName, beanType)); } } - return unmodifiableList(beans); } From b954dadc09cc5b72731c192275407c13e4fb414d Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Mon, 6 Jan 2025 10:14:47 +0800 Subject: [PATCH 2/4] Polish #57 : BeanUtils --- .../src/main/java/io/microsphere/spring/beans/BeanUtils.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java index efd29ddd..9cb1c745 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java @@ -69,10 +69,6 @@ public abstract class BeanUtils extends BaseUtils { private static final Logger logger = LoggerFactory.getLogger(BeanUtils.class); - private static final String[] EMPTY_BEAN_NAMES = new String[0]; - - private static final Class APPLICATION_STARTUP_CLASS = resolveClass("org.springframework.core.metrics.ApplicationStartup"); - /** * Is Bean Present or not? * From c0d00eafd73b7325ab2a393585df41a4b965209d Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Mon, 6 Jan 2025 10:25:04 +0800 Subject: [PATCH 3/4] Polish #57 : BeanUtils --- .../io/microsphere/spring/beans/BeanUtils.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java index 9cb1c745..b51e3e64 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java @@ -30,7 +30,6 @@ import org.springframework.context.ResourceLoaderAware; import org.springframework.core.Ordered; import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import org.springframework.util.ObjectUtils; import javax.annotation.Nullable; import java.util.ArrayList; @@ -44,9 +43,6 @@ import static io.microsphere.spring.context.ApplicationContextUtils.asConfigurableApplicationContext; import static io.microsphere.spring.context.ApplicationContextUtils.getApplicationContextAwareProcessor; import static io.microsphere.util.ArrayUtils.isEmpty; -import static io.microsphere.util.ClassLoaderUtils.getClassLoader; -import static io.microsphere.util.ClassLoaderUtils.isPresent; -import static io.microsphere.util.ClassLoaderUtils.resolveClass; import static java.lang.String.format; import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableList; @@ -90,7 +86,7 @@ public static boolean isBeanPresent(ListableBeanFactory beanFactory, Class be */ public static boolean isBeanPresent(ListableBeanFactory beanFactory, Class beanClass, boolean includingAncestors) { String[] beanNames = getBeanNames(beanFactory, beanClass, includingAncestors); - return !ObjectUtils.isEmpty(beanNames); + return !isEmpty(beanNames); } /** @@ -113,19 +109,17 @@ public static boolean isBeanPresent(ListableBeanFactory beanFactory, String bean * @return If present , return true , or false */ public static boolean isBeanPresent(ListableBeanFactory beanFactory, String beanClassName, boolean includingAncestors) { - boolean present = false; ClassLoader classLoader = null; if (beanFactory instanceof ConfigurableBeanFactory) { ConfigurableBeanFactory configurableBeanFactory = (ConfigurableBeanFactory) beanFactory; classLoader = configurableBeanFactory.getBeanClassLoader(); - } else { - classLoader = getClassLoader(beanFactory.getClass()); } - if (isPresent(beanClassName, classLoader)) { - Class beanClass = resolveClassName(beanClassName, classLoader); - present = isBeanPresent(beanFactory, beanClass, includingAncestors); + + Class beanClass = resolveClassName(beanClassName, classLoader); + if (beanClass == null) { + return false; } - return present; + return isBeanPresent(beanFactory, beanClass, includingAncestors); } From 3e77d1981066d936fbc40b4bef07904ce152b524 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Mon, 6 Jan 2025 10:41:27 +0800 Subject: [PATCH 4/4] Polish #58 --- .../microsphere/spring/beans/BeanUtils.java | 8 ++--- ...tractInjectionPointDependencyResolver.java | 4 +-- .../DefaultBeanDependencyResolver.java | 36 +++++++++---------- .../AnnotatedInjectionBeanPostProcessor.java | 4 +-- .../beans/factory/support/BeanRegistrar.java | 4 +-- .../ListenableAutowireCandidateResolver.java | 4 +-- ...ingAutowireCandidateResolvingListener.java | 4 +-- .../AnnotatedBeanDefinitionRegistryUtils.java | 22 ++++++------ ...DependencyAnalysisBeanFactoryListener.java | 10 +++--- .../OnceApplicationContextEventListener.java | 4 +-- ...ntiationSingletonsBeanFactoryListener.java | 2 +- .../support/ConversionServiceResolver.java | 4 +-- .../spring/core/env/EnvironmentUtils.java | 4 +-- .../core/env/LoggingEnvironmentListener.java | 8 ++--- .../spring/core/env/PropertySourcesUtils.java | 10 +++--- .../support/SpringFactoriesLoaderUtils.java | 2 +- .../config/P6DataSourceBeanPostProcessor.java | 6 ++-- .../InterceptingHandlerMethodProcessor.java | 4 +-- 18 files changed, 70 insertions(+), 70 deletions(-) diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java index b51e3e64..3a595086 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/BeanUtils.java @@ -223,8 +223,8 @@ public static Class resolveBeanType(String beanClassName, ClassLoader classLo public static T getOptionalBean(ListableBeanFactory beanFactory, Class beanClass, boolean includingAncestors) throws BeansException { String[] beanNames = getBeanNames(beanFactory, beanClass, includingAncestors); if (isEmpty(beanNames)) { - if (logger.isDebugEnabled()) { - logger.debug("The bean [ class : " + beanClass.getName() + " ] can't be found "); + if (logger.isTraceEnabled()) { + logger.trace("The bean [ class : " + beanClass.getName() + " ] can't be found "); } return null; } @@ -271,8 +271,8 @@ public static T getBeanIfAvailable(BeanFactory beanFactory, String beanName, return beanFactory.getBean(beanName, beanType); } - if (logger.isDebugEnabled()) { - logger.debug(format("The bean[name : %s , type : %s] can't be found in Spring BeanFactory", beanName, beanType.getName())); + if (logger.isTraceEnabled()) { + logger.trace(format("The bean[name : %s , type : %s] can't be found in Spring BeanFactory", beanName, beanType.getName())); } return null; } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/AbstractInjectionPointDependencyResolver.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/AbstractInjectionPointDependencyResolver.java index e40f2ce5..c7e5d54a 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/AbstractInjectionPointDependencyResolver.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/AbstractInjectionPointDependencyResolver.java @@ -68,7 +68,7 @@ public void resolve(Field field, ConfigurableListableBeanFactory beanFactory, Se public void resolve(Method method, ConfigurableListableBeanFactory beanFactory, Set dependentBeanNames) { int parametersCount = method.getParameterCount(); if (parametersCount < 1) { - logger.debug("The no-argument method[{}] will be ignored", method); + logger.trace("The no-argument method[{}] will be ignored", method); return; } Parameter[] parameters = method.getParameters(); @@ -82,7 +82,7 @@ public void resolve(Method method, ConfigurableListableBeanFactory beanFactory, public void resolve(Constructor constructor, ConfigurableListableBeanFactory beanFactory, Set dependentBeanNames) { int parametersCount = constructor.getParameterCount(); if (parametersCount < 1) { - logger.debug("The no-argument constructor[{}] will be ignored", constructor); + logger.trace("The no-argument constructor[{}] will be ignored", constructor); return; } Parameter[] parameters = constructor.getParameters(); diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/DefaultBeanDependencyResolver.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/DefaultBeanDependencyResolver.java index 0beef181..89094cb5 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/DefaultBeanDependencyResolver.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/DefaultBeanDependencyResolver.java @@ -203,8 +203,8 @@ private void preProcessLoadBeanClass(String beanName, RootBeanDefinition beanDef executorService.execute(() -> { Class beanClass = loadClass(beanClassName, classLoader, true); beanDefinition.setBeanClass(beanClass); - if (logger.isDebugEnabled()) { - logger.debug("The bean[name : '{}'] class[name : '{}'] was loaded", beanName, beanClassName); + if (logger.isTraceEnabled()) { + logger.trace("The bean[name : '{}'] class[name : '{}'] was loaded", beanName, beanClassName); } }); } @@ -259,7 +259,7 @@ private void flattenDependentBeanNamesMap(Map> dependentBean for (String nonRootBeanName : nonRootBeanNames) { if (dependentBeanNamesMap.remove(nonRootBeanName) != null) { - logger.debug("Non Root Bean name was removed : {}", nonRootBeanName); + logger.trace("Non Root Bean name was removed : {}", nonRootBeanName); } } @@ -269,9 +269,9 @@ private void flattenDependentBeanNamesMap(Map> dependentBean } private void logDependentBeanNames(Map> dependentBeanNamesMap) { - if (logger.isDebugEnabled()) { + if (logger.isTraceEnabled()) { for (Map.Entry> entry : dependentBeanNamesMap.entrySet()) { - logger.debug("The bean : '{}' <- bean dependencies : {}", entry.getKey(), entry.getValue()); + logger.trace("The bean : '{}' <- bean dependencies : {}", entry.getKey(), entry.getValue()); } } } @@ -332,7 +332,7 @@ private void resolveInjectionPointsDependentBeanNames(String beanName, RootBeanD boolean isInterfaceBean = beanClass.isInterface(); if (isInterfaceBean) { - logger.debug("The resolved type of BeanDefinition : {}", beanClass.getName()); + logger.trace("The resolved type of BeanDefinition : {}", beanClass.getName()); return; } @@ -348,8 +348,8 @@ private void resolveMethodParametersDependentBeanNames(String beanName, Class be do { doWithLocalMethods(targetClass, method -> { if (isStatic(method)) { - if (logger.isDebugEnabled()) { - logger.debug("The Injection Point[bean : '{}' , class : {}] is not supported on static method : {}", beanName, method.getDeclaringClass().getName(), method); + if (logger.isTraceEnabled()) { + logger.trace("The Injection Point[bean : '{}' , class : {}] is not supported on static method : {}", beanName, method.getDeclaringClass().getName(), method); } return; } @@ -363,7 +363,7 @@ private void resolveMethodParametersDependentBeanNames(String beanName, Class be if (method.equals(getMostSpecificMethod(method, beanClass))) { if (isBeanMemberResolved(method)) { - logger.debug("The beans'[name : '{}'] method has been resolved : {}", beanName, method); + logger.trace("The beans'[name : '{}'] method has been resolved : {}", beanName, method); } else { resolvers.resolve(method, beanFactory, dependentBeanNames); addResolvedBeanMember(method); @@ -383,13 +383,13 @@ private void resolveFieldDependentBeanNames(String beanName, Class beanClass, De do { doWithLocalFields(targetClass, field -> { if (isStatic(field)) { - if (logger.isDebugEnabled()) { - logger.debug("The Injection Point[bean : '{}' , class : {}] is not supported on static field : {}", beanName, field.getDeclaringClass().getName(), field); + if (logger.isTraceEnabled()) { + logger.trace("The Injection Point[bean : '{}' , class : {}] is not supported on static field : {}", beanName, field.getDeclaringClass().getName(), field); } return; } if (isBeanMemberResolved(field)) { - logger.debug("The beans'[name : '{}'] field has been resolved : {}", beanName, field); + logger.trace("The beans'[name : '{}'] field has been resolved : {}", beanName, field); } else { resolvers.resolve(field, beanFactory, dependentBeanNames); addResolvedBeanMember(field); @@ -410,7 +410,7 @@ private void removeReadyBeanNames(Set dependentBeanNames, DefaultListabl while (iterator.hasNext()) { String dependentBeanName = iterator.next(); if (isBeanReady(dependentBeanName, beanFactory)) { - logger.debug("The dependent bean name['{}'] is removed since it's ready!", dependentBeanName); + logger.trace("The dependent bean name['{}'] is removed since it's ready!", dependentBeanName); iterator.remove(); } } @@ -481,7 +481,7 @@ private void resolveConstructionParametersDependentBeanNames(String beanName, Ro } else { Constructor constructor = constructors[0]; if (isBeanMemberResolved(constructor)) { - logger.debug("The beans'[name : '{}'] constructor has been resolved : {}", beanName, constructor); + logger.trace("The beans'[name : '{}'] constructor has been resolved : {}", beanName, constructor); } else { resolvers.resolve(constructor, beanFactory, dependentBeanNames); addResolvedBeanMember(constructor); @@ -489,7 +489,7 @@ private void resolveConstructionParametersDependentBeanNames(String beanName, Ro } } else { // the @Bean or customized Method Definition if (isBeanMemberResolved(factoryMethod)) { - logger.debug("The beans'[name : '{}'] factory-method has been resolved : {}", beanName, factoryMethod); + logger.trace("The beans'[name : '{}'] factory-method has been resolved : {}", beanName, factoryMethod); } else { resolvers.resolve(factoryMethod, beanFactory, dependentBeanNames); addResolvedBeanMember(factoryMethod); @@ -547,7 +547,7 @@ private Map getEligibleBeanDefinitionsMap(DefaultLis continue; } if (beanFactory.isCurrentlyInCreation(beanName)) { - logger.debug("The Bean[name : '{}'] is creating currently", beanName); + logger.trace("The Bean[name : '{}'] is creating currently", beanName); continue; } @@ -594,8 +594,8 @@ private RootBeanDefinition getEligibleBeanDefinition(BeanDefinition beanDefiniti private boolean isBeanReady(String beanName, DefaultListableBeanFactory beanFactory) { boolean ready = beanFactory.containsSingleton(beanName); - if (ready && logger.isDebugEnabled()) { - logger.debug("The Bean[name : '{}'] is ready in the BeanFactory[id : '{}']", beanName, beanFactory.getSerializationId()); + if (ready && logger.isTraceEnabled()) { + logger.trace("The Bean[name : '{}'] is ready in the BeanFactory[id : '{}']", beanName, beanFactory.getSerializationId()); } return ready; } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/annotation/AnnotatedInjectionBeanPostProcessor.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/annotation/AnnotatedInjectionBeanPostProcessor.java index f1e8f1c2..7ed9404f 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/annotation/AnnotatedInjectionBeanPostProcessor.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/annotation/AnnotatedInjectionBeanPostProcessor.java @@ -571,8 +571,8 @@ private void registerDependentBeans(String beanName, Set injectedBeanNam if (this.beanFactory.containsBean(injectedBeanName)) { this.beanFactory.registerDependentBean(injectedBeanName, beanName); } - if (logger.isDebugEnabled()) { - logger.debug("Injected by type from bean name '" + beanName + + if (logger.isTraceEnabled()) { + logger.trace("Injected by type from bean name '" + beanName + "' to bean named '" + injectedBeanName + "'"); } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/BeanRegistrar.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/BeanRegistrar.java index d21571be..5dfea65e 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/BeanRegistrar.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/BeanRegistrar.java @@ -163,8 +163,8 @@ public static final boolean registerBeanDefinition(BeanDefinitionRegistry regist } else { try { registry.registerBeanDefinition(beanName, beanDefinition); - if (logger.isDebugEnabled()) { - logger.debug("The bean[name : '{}' , role : {}] definition [{}] has been registered.", beanName, beanDefinition.getRole(), beanDefinition); + if (logger.isTraceEnabled()) { + logger.trace("The bean[name : '{}' , role : {}] definition [{}] has been registered.", beanName, beanDefinition.getRole(), beanDefinition); } registered = true; } catch (BeanDefinitionStoreException e) { diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/ListenableAutowireCandidateResolver.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/ListenableAutowireCandidateResolver.java index b466fe07..2ef2cc2e 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/ListenableAutowireCandidateResolver.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/ListenableAutowireCandidateResolver.java @@ -176,8 +176,8 @@ public void wrap(BeanFactory beanFactory) { } return; } - if (logger.isDebugEnabled()) { - logger.debug("The ListenableAutowireCandidateResolver bean[name : '{}'] is enabled.", this.beanName); + if (logger.isTraceEnabled()) { + logger.trace("The ListenableAutowireCandidateResolver bean[name : '{}'] is enabled.", this.beanName); } DefaultListableBeanFactory dbf = asDefaultListableBeanFactory(beanFactory); AutowireCandidateResolver autowireCandidateResolver = dbf.getAutowireCandidateResolver(); diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/LoggingAutowireCandidateResolvingListener.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/LoggingAutowireCandidateResolvingListener.java index cbe2e1bd..9e43f679 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/LoggingAutowireCandidateResolvingListener.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/beans/factory/support/LoggingAutowireCandidateResolvingListener.java @@ -47,8 +47,8 @@ public void lazyProxyResolved(DependencyDescriptor descriptor, String beanName, } protected void log(String messagePattern, Object... args) { - if (logger.isDebugEnabled()) { - logger.debug(messagePattern, args); + if (logger.isTraceEnabled()) { + logger.trace(messagePattern, args); } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/annotation/AnnotatedBeanDefinitionRegistryUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/annotation/AnnotatedBeanDefinitionRegistryUtils.java index 89d23f7c..147fdfa1 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/annotation/AnnotatedBeanDefinitionRegistryUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/annotation/AnnotatedBeanDefinitionRegistryUtils.java @@ -68,8 +68,8 @@ public static boolean isPresentBean(BeanDefinitionRegistry registry, Class an Class targetClass = resolveClassName(className, classLoader); present = nullSafeEquals(targetClass, annotatedClass); if (present) { - if (logger.isDebugEnabled()) { - logger.debug(format("The annotatedClass[class : %s , bean name : %s] was present in registry[%s]", + if (logger.isTraceEnabled()) { + logger.trace(format("The annotatedClass[class : %s , bean name : %s] was present in registry[%s]", className, beanName, registry)); } break; @@ -106,8 +106,8 @@ public static void registerBeans(BeanDefinitionRegistry registry, Class... an AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(registry); - if (logger.isDebugEnabled()) { - logger.debug(registry.getClass().getSimpleName() + " will register annotated classes : " + asList(annotatedClasses) + " ."); + if (logger.isTraceEnabled()) { + logger.trace(registry.getClass().getSimpleName() + " will register annotated classes : " + asList(annotatedClasses) + " ."); } reader.register(classesToRegister.toArray(EMPTY_CLASS_ARRAY)); @@ -127,10 +127,10 @@ public static int scanBasePackages(BeanDefinitionRegistry registry, String... ba if (!ObjectUtils.isEmpty(basePackages)) { - boolean debugEnabled = logger.isDebugEnabled(); + boolean traceEnabled = logger.isTraceEnabled(); - if (debugEnabled) { - logger.debug(registry.getClass().getSimpleName() + " will scan base packages " + Arrays.asList(basePackages) + "."); + if (traceEnabled) { + logger.trace(registry.getClass().getSimpleName() + " will scan base packages " + Arrays.asList(basePackages) + "."); } List registeredBeanNames = Arrays.asList(registry.getBeanDefinitionNames()); @@ -142,14 +142,14 @@ public static int scanBasePackages(BeanDefinitionRegistry registry, String... ba scannedBeanNames.addAll(Arrays.asList(registry.getBeanDefinitionNames())); scannedBeanNames.removeAll(registeredBeanNames); - if (debugEnabled) { - logger.debug("The Scanned Components[ count : " + count + "] under base packages " + Arrays.asList(basePackages) + " : "); + if (traceEnabled) { + logger.trace("The Scanned Components[ count : " + count + "] under base packages " + Arrays.asList(basePackages) + " : "); } for (String scannedBeanName : scannedBeanNames) { BeanDefinition scannedBeanDefinition = registry.getBeanDefinition(scannedBeanName); - if (debugEnabled) { - logger.debug("Component [ name : " + scannedBeanName + " , class : " + scannedBeanDefinition.getBeanClassName() + " ]"); + if (traceEnabled) { + logger.trace("Component [ name : " + scannedBeanName + " , class : " + scannedBeanDefinition.getBeanClassName() + " ]"); } } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/DependencyAnalysisBeanFactoryListener.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/DependencyAnalysisBeanFactoryListener.java index 19b2c29e..534a3791 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/DependencyAnalysisBeanFactoryListener.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/DependencyAnalysisBeanFactoryListener.java @@ -120,16 +120,16 @@ private void flattenDependentBeanNamesMap(Map> dependentBean private void logDependenciesTrace(String dependentBeanName, Map.Entry> dependencies) { - if (logger.isDebugEnabled()) { - logger.debug("The bean dependency : '{}' -> beans : {}", dependentBeanName, dependencies.getValue()); + if (logger.isTraceEnabled()) { + logger.trace("The bean dependency : '{}' -> beans : {}", dependentBeanName, dependencies.getValue()); } } private void logDependentTrace(Map> dependentBeanNamesMap) { - if (logger.isDebugEnabled()) { + if (logger.isTraceEnabled()) { for (Map.Entry> entry : dependentBeanNamesMap.entrySet()) { - logger.debug("The bean : '{}' <- bean dependencies : {}", entry.getKey(), entry.getValue()); + logger.trace("The bean : '{}' <- bean dependencies : {}", entry.getKey(), entry.getValue()); } } } @@ -346,7 +346,7 @@ private List getNonLazyInitSingletonMergedBeanDefinitionHo for (int i = 0; i < beansCount; i++) { String beanName = beanNames[i]; if (beanFactory.containsSingleton(beanName)) { - logger.debug("The Bean[name : '{}'] is ready", beanName); + logger.trace("The Bean[name : '{}'] is ready", beanName); continue; } BeanDefinition beanDefinition = beanFactory.getMergedBeanDefinition(beanName); diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/OnceApplicationContextEventListener.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/OnceApplicationContextEventListener.java index cd6bea86..234a2a34 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/OnceApplicationContextEventListener.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/OnceApplicationContextEventListener.java @@ -72,8 +72,8 @@ private boolean isOriginalEventSource(ApplicationEvent event) { boolean originalEventSource = nullSafeEquals(getApplicationContext(), event.getSource()); if (!originalEventSource) { - if (logger.isDebugEnabled()) { - logger.debug("The source of event[" + event.getSource() + "] is not original!"); + if (logger.isTraceEnabled()) { + logger.trace("The source of event[" + event.getSource() + "] is not original!"); } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/ParallelPreInstantiationSingletonsBeanFactoryListener.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/ParallelPreInstantiationSingletonsBeanFactoryListener.java index 778cf360..7a71f0a5 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/ParallelPreInstantiationSingletonsBeanFactoryListener.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/context/event/ParallelPreInstantiationSingletonsBeanFactoryListener.java @@ -121,7 +121,7 @@ private void preInstantiateSingletonsInParallel(Map> depende executorService.submit(() -> { for (String beanName : beanNamesInDependencyPath) { Object bean = beanFactory.getBean(beanName); - logger.debug("The bean[name : '{}'] was created : {}", beanName, bean); + logger.trace("The bean[name : '{}'] was created : {}", beanName, bean); } return null; }); diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/convert/support/ConversionServiceResolver.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/convert/support/ConversionServiceResolver.java index 5c745cf2..c12c5658 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/convert/support/ConversionServiceResolver.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/convert/support/ConversionServiceResolver.java @@ -118,8 +118,8 @@ protected ConversionService createDefaultConversionService() { } private void debug(String message, Object... args) { - if (logger.isDebugEnabled()) { - logger.debug(args.length < 1 ? message : format(message, args)); + if (logger.isTraceEnabled()) { + logger.trace(args.length < 1 ? message : format(message, args)); } } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/EnvironmentUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/EnvironmentUtils.java index d555cd77..a65132b0 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/EnvironmentUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/EnvironmentUtils.java @@ -190,12 +190,12 @@ public static T resolvePlaceholders(Environment environment, String property String resolvedPropertyValue = environment.resolvePlaceholders(propertyValue); if (conversionService.canConvert(String.class, targetType)) { targetValue = conversionService.convert(resolvedPropertyValue, targetType); - logger.debug("The property value[origin : {} , resolved : {}] was converted to be {}(type :{})!", propertyValue, resolvedPropertyValue, + logger.trace("The property value[origin : {} , resolved : {}] was converted to be {}(type :{})!", propertyValue, resolvedPropertyValue, targetValue, targetType); } else { targetValue = defaultValue; - logger.debug("The property value[origin : {} , resolved : {}] can't be converted to be the target type[{}], take the default value({}) as result!", + logger.trace("The property value[origin : {} , resolved : {}] can't be converted to be the target type[{}], take the default value({}) as result!", propertyValue, resolvedPropertyValue, targetValue, targetType); } return targetValue; diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/LoggingEnvironmentListener.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/LoggingEnvironmentListener.java index 9faa23c3..457dd329 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/LoggingEnvironmentListener.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/LoggingEnvironmentListener.java @@ -248,14 +248,14 @@ public void afterSetValueSeparator(ConfigurablePropertyResolver propertyResolver } protected void log(String message) { - if (logger.isDebugEnabled()) { - logger.debug(message); + if (logger.isTraceEnabled()) { + logger.trace(message); } } protected void log(String messagePattern, Object... args) { - if (logger.isDebugEnabled()) { - logger.debug(messagePattern, args); + if (logger.isTraceEnabled()) { + logger.trace(messagePattern, args); } } } diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/PropertySourcesUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/PropertySourcesUtils.java index 9d903801..dc7a0284 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/PropertySourcesUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/env/PropertySourcesUtils.java @@ -77,16 +77,16 @@ public static > T getPropertySource(ConfigurableEnvi PropertySource propertySource = propertySources.get(propertySourceName); T targetPropertySource = null; if (propertySource == null) { - logger.debug("The '{}' PropertySource can't be found!", propertySourceName); + logger.trace("The '{}' PropertySource can't be found!", propertySourceName); if (propertySourceSupplierIfAbsent != null) { targetPropertySource = propertySourceSupplierIfAbsent.get(); if (targetPropertySource != null) { - logger.debug("A new PropertySource[{}] will be created.", targetPropertySource); + logger.trace("A new PropertySource[{}] will be created.", targetPropertySource); propertySources.addLast(targetPropertySource); } } } else if (propertySourceType.isInstance(propertySource)) { - logger.debug("The '{}' PropertySource[type: {}] was found!", propertySourceName, propertySource.getClass().getName()); + logger.trace("The '{}' PropertySource[type: {}] was found!", propertySourceName, propertySource.getClass().getName()); targetPropertySource = propertySourceType.cast(propertySource); } else { logger.warn("The '{}' PropertySource is not a {} instance, actual type : {}", propertySource.getClass().getName(), @@ -322,7 +322,7 @@ public static Map getDefaultProperties(ConfigurableEnvironment e MapPropertySource defaultPropertiesPropertySource = getDefaultPropertiesPropertySource(environment, createIfAbsent); if (defaultPropertiesPropertySource != null) { defaultProperties = defaultPropertiesPropertySource.getSource(); - logger.debug("The 'defaultProperties' property was obtained successfully, and the current content is: {}", defaultProperties); + logger.trace("The 'defaultProperties' property was obtained successfully, and the current content is: {}", defaultProperties); } return defaultProperties; } @@ -356,7 +356,7 @@ public static MapPropertySource getDefaultPropertiesPropertySource(ConfigurableE defaultPropertiesPropertySource = new MapPropertySource(name, new HashMap<>()); propertySources.addLast(defaultPropertiesPropertySource); } else if (propertySource instanceof MapPropertySource) { - logger.debug("The 'defaultProperties' property was initialized"); + logger.trace("The 'defaultProperties' property was initialized"); defaultPropertiesPropertySource = (MapPropertySource) propertySource; } else { logger.warn("'defaultProperties' PropertySource[name: {}] is not an MapPropertySource instance; it is actually: {}", name, propertySource.getClass().getName()); diff --git a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/io/support/SpringFactoriesLoaderUtils.java b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/io/support/SpringFactoriesLoaderUtils.java index 64e3f56a..cc815d64 100644 --- a/microsphere-spring-context/src/main/java/io/microsphere/spring/core/io/support/SpringFactoriesLoaderUtils.java +++ b/microsphere-spring-context/src/main/java/io/microsphere/spring/core/io/support/SpringFactoriesLoaderUtils.java @@ -106,7 +106,7 @@ public static List loadFactories(@Nullable ConfigurableApplicationContext int factorySize = factoryClassNames.size(); if (factorySize < 1) { - logger.debug("No factory class {} were loaded from SpringFactoriesLoader[{}]", factoryClass.getName(), + logger.trace("No factory class {} were loaded from SpringFactoriesLoader[{}]", factoryClass.getName(), SpringFactoriesLoader.FACTORIES_RESOURCE_LOCATION); return emptyList(); } diff --git a/microsphere-spring-jdbc/src/main/java/io/microsphere/spring/jdbc/p6spy/beans/factory/config/P6DataSourceBeanPostProcessor.java b/microsphere-spring-jdbc/src/main/java/io/microsphere/spring/jdbc/p6spy/beans/factory/config/P6DataSourceBeanPostProcessor.java index 49bf53c9..a2f89e25 100644 --- a/microsphere-spring-jdbc/src/main/java/io/microsphere/spring/jdbc/p6spy/beans/factory/config/P6DataSourceBeanPostProcessor.java +++ b/microsphere-spring-jdbc/src/main/java/io/microsphere/spring/jdbc/p6spy/beans/factory/config/P6DataSourceBeanPostProcessor.java @@ -51,17 +51,17 @@ protected DataSource doPostProcessAfterInitialization(DataSource bean, String be DataSource targetDataSource = bean; if (excludedDataSourceBeanNames.contains(beanName)) { - logger.debug("The DataSource bean[name : '{}'] is excluded, it caused by Spring property[name : '{}']", beanName, EXCLUDED_DATASOURCE_BEAN_NAMES_PROPERTY_NAME); + logger.trace("The DataSource bean[name : '{}'] is excluded, it caused by Spring property[name : '{}']", beanName, EXCLUDED_DATASOURCE_BEAN_NAMES_PROPERTY_NAME); } else { try { DataSource datasource = bean.unwrap(DataSource.class); targetDataSource = new P6DataSource(datasource); } catch (SQLException e) { - logger.debug("The DataSource bean[name : '{}' , class : '{}'] can't unwrap to be an instance DataSource", beanName, bean.getClass().getName()); + logger.trace("The DataSource bean[name : '{}' , class : '{}'] can't unwrap to be an instance DataSource", beanName, bean.getClass().getName()); } } - logger.debug("The DataSource bean[name : '{}'] {} -> {}", beanName, bean, targetDataSource); + logger.trace("The DataSource bean[name : '{}'] {} -> {}", beanName, bean, targetDataSource); return targetDataSource; } diff --git a/microsphere-spring-webmvc/src/main/java/io/microsphere/spring/webmvc/method/support/InterceptingHandlerMethodProcessor.java b/microsphere-spring-webmvc/src/main/java/io/microsphere/spring/webmvc/method/support/InterceptingHandlerMethodProcessor.java index 1c7a0aa0..b30007b5 100644 --- a/microsphere-spring-webmvc/src/main/java/io/microsphere/spring/webmvc/method/support/InterceptingHandlerMethodProcessor.java +++ b/microsphere-spring-webmvc/src/main/java/io/microsphere/spring/webmvc/method/support/InterceptingHandlerMethodProcessor.java @@ -127,7 +127,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { MethodParameterContext methodParameterContext = getParameterContext(parameter); if (methodParameterContext == null) { - logger.debug("The MethodParameterContext can't be found by the MethodParameter[{}]", parameter); + logger.trace("The MethodParameterContext can't be found by the MethodParameter[{}]", parameter); return null; } @@ -149,7 +149,7 @@ public void handleReturnValue(@Nullable Object returnValue, MethodParameter retu NativeWebRequest webRequest) throws Exception { ReturnTypeContext context = getReturnTypeContext(returnType); if (context == null) { - logger.debug("The ReturnTypeContext can't be found by the return type[{}]", returnType); + logger.trace("The ReturnTypeContext can't be found by the return type[{}]", returnType); return; }