类 ApplicationUtils

  • 所有已实现的接口:
    org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>

    public class ApplicationUtils
    extends java.lang.Object
    implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
    Nacos global tool class.
    作者:
    liaochuntao
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      private static org.springframework.context.ApplicationContext applicationContext  
      private static boolean started  
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      static boolean containsBean​(java.lang.String name)  
      static boolean containsBeanDefinition​(java.lang.String beanName)  
      static boolean containsLocalBean​(java.lang.String name)  
      static <A extends java.lang.annotation.Annotation>
      A
      findAnnotationOnBean​(java.lang.String beanName, java.lang.Class<A> annotationType)  
      static java.lang.String[] getAliases​(java.lang.String name)  
      static org.springframework.context.ApplicationContext getApplicationContext()  
      static java.lang.String getApplicationName()  
      static org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()  
      static <T> T getBean​(java.lang.Class<T> requiredType)  
      static <T> T getBean​(java.lang.Class<T> requiredType, java.lang.Object... args)  
      static java.lang.Object getBean​(java.lang.String name)  
      static <T> T getBean​(java.lang.String name, java.lang.Class<T> requiredType)  
      static java.lang.Object getBean​(java.lang.String name, java.lang.Object... args)  
      static int getBeanDefinitionCount()  
      static java.lang.String[] getBeanDefinitionNames()  
      static <T> void getBeanIfExist​(java.lang.Class<T> requiredType, java.util.function.Consumer<T> consumer)  
      static java.lang.String[] getBeanNamesForAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)  
      static java.lang.String[] getBeanNamesForType​(java.lang.Class<?> type)  
      static java.lang.String[] getBeanNamesForType​(java.lang.Class<?> type, boolean includeNonSingletons, boolean allowEagerInit)  
      static java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType type)  
      static <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(java.lang.Class<T> requiredType)  
      static <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(org.springframework.core.ResolvableType requiredType)  
      static <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> type)  
      static <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)  
      static java.util.Map<java.lang.String,​java.lang.Object> getBeansWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)  
      static java.lang.ClassLoader getClassLoader()  
      static java.lang.String getDisplayName()  
      static java.lang.String getId()  
      static java.lang.String getMessage​(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)  
      static java.lang.String getMessage​(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)  
      static java.lang.String getMessage​(org.springframework.context.MessageSourceResolvable resolvable, java.util.Locale locale)  
      static org.springframework.context.ApplicationContext getParent()  
      static org.springframework.beans.factory.BeanFactory getParentBeanFactory()  
      static org.springframework.core.io.Resource getResource​(java.lang.String location)  
      static org.springframework.core.io.Resource[] getResources​(java.lang.String locationPattern)  
      static long getStartupDate()  
      static java.lang.Class<?> getType​(java.lang.String name)  
      void initialize​(org.springframework.context.ConfigurableApplicationContext context)  
      static void injectContext​(org.springframework.context.ConfigurableApplicationContext context)  
      static boolean isPrototype​(java.lang.String name)  
      static boolean isSingleton​(java.lang.String name)  
      static boolean isStarted()  
      static boolean isTypeMatch​(java.lang.String name, java.lang.Class<?> typeToMatch)  
      static boolean isTypeMatch​(java.lang.String name, org.springframework.core.ResolvableType typeToMatch)  
      static void publishEvent​(java.lang.Object event)  
      static void setStarted​(boolean started)  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • applicationContext

        private static org.springframework.context.ApplicationContext applicationContext
      • started

        private static boolean started
    • 构造器详细资料

      • ApplicationUtils

        public ApplicationUtils()
    • 方法详细资料

      • getId

        public static java.lang.String getId()
      • getApplicationName

        public static java.lang.String getApplicationName()
      • getDisplayName

        public static java.lang.String getDisplayName()
      • getStartupDate

        public static long getStartupDate()
      • getParent

        public static org.springframework.context.ApplicationContext getParent()
      • getAutowireCapableBeanFactory

        public static org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()
                                                                                                                 throws java.lang.IllegalStateException
        抛出:
        java.lang.IllegalStateException
      • isStarted

        public static boolean isStarted()
      • setStarted

        public static void setStarted​(boolean started)
      • getParentBeanFactory

        public static org.springframework.beans.factory.BeanFactory getParentBeanFactory()
      • containsLocalBean

        public static boolean containsLocalBean​(java.lang.String name)
      • containsBeanDefinition

        public static boolean containsBeanDefinition​(java.lang.String beanName)
      • getBeanDefinitionCount

        public static int getBeanDefinitionCount()
      • getBeanDefinitionNames

        public static java.lang.String[] getBeanDefinitionNames()
      • getBeanNamesForType

        public static java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType type)
      • getBeanNamesForType

        public static java.lang.String[] getBeanNamesForType​(java.lang.Class<?> type)
      • getBeanNamesForType

        public static java.lang.String[] getBeanNamesForType​(java.lang.Class<?> type,
                                                             boolean includeNonSingletons,
                                                             boolean allowEagerInit)
      • getBeansOfType

        public static <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> type)
                                                                          throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBeansOfType

        public static <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> type,
                                                                                 boolean includeNonSingletons,
                                                                                 boolean allowEagerInit)
                                                                          throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBeanNamesForAnnotation

        public static java.lang.String[] getBeanNamesForAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
      • getBeansWithAnnotation

        public static java.util.Map<java.lang.String,​java.lang.Object> getBeansWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
                                                                                             throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • findAnnotationOnBean

        public static <A extends java.lang.annotation.Annotation> A findAnnotationOnBean​(java.lang.String beanName,
                                                                                         java.lang.Class<A> annotationType)
                                                                                  throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • getBean

        public static java.lang.Object getBean​(java.lang.String name)
                                        throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBean

        public static <T> T getBean​(java.lang.String name,
                                    java.lang.Class<T> requiredType)
                             throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBean

        public static java.lang.Object getBean​(java.lang.String name,
                                               java.lang.Object... args)
                                        throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBean

        public static <T> T getBean​(java.lang.Class<T> requiredType)
                             throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBeanIfExist

        public static <T> void getBeanIfExist​(java.lang.Class<T> requiredType,
                                              java.util.function.Consumer<T> consumer)
                                       throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBean

        public static <T> T getBean​(java.lang.Class<T> requiredType,
                                    java.lang.Object... args)
                             throws org.springframework.beans.BeansException
        抛出:
        org.springframework.beans.BeansException
      • getBeanProvider

        public static <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(java.lang.Class<T> requiredType)
      • getBeanProvider

        public static <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(org.springframework.core.ResolvableType requiredType)
      • containsBean

        public static boolean containsBean​(java.lang.String name)
      • isSingleton

        public static boolean isSingleton​(java.lang.String name)
                                   throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • isPrototype

        public static boolean isPrototype​(java.lang.String name)
                                   throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • isTypeMatch

        public static boolean isTypeMatch​(java.lang.String name,
                                          org.springframework.core.ResolvableType typeToMatch)
                                   throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • isTypeMatch

        public static boolean isTypeMatch​(java.lang.String name,
                                          java.lang.Class<?> typeToMatch)
                                   throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • getType

        public static java.lang.Class<?> getType​(java.lang.String name)
                                          throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        抛出:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • getAliases

        public static java.lang.String[] getAliases​(java.lang.String name)
      • publishEvent

        public static void publishEvent​(java.lang.Object event)
      • getMessage

        public static java.lang.String getMessage​(java.lang.String code,
                                                  java.lang.Object[] args,
                                                  java.lang.String defaultMessage,
                                                  java.util.Locale locale)
      • getMessage

        public static java.lang.String getMessage​(java.lang.String code,
                                                  java.lang.Object[] args,
                                                  java.util.Locale locale)
                                           throws org.springframework.context.NoSuchMessageException
        抛出:
        org.springframework.context.NoSuchMessageException
      • getMessage

        public static java.lang.String getMessage​(org.springframework.context.MessageSourceResolvable resolvable,
                                                  java.util.Locale locale)
                                           throws org.springframework.context.NoSuchMessageException
        抛出:
        org.springframework.context.NoSuchMessageException
      • getResources

        public static org.springframework.core.io.Resource[] getResources​(java.lang.String locationPattern)
                                                                   throws java.io.IOException
        抛出:
        java.io.IOException
      • getResource

        public static org.springframework.core.io.Resource getResource​(java.lang.String location)
      • getClassLoader

        public static java.lang.ClassLoader getClassLoader()
      • getApplicationContext

        public static org.springframework.context.ApplicationContext getApplicationContext()
      • injectContext

        public static void injectContext​(org.springframework.context.ConfigurableApplicationContext context)
      • initialize

        public void initialize​(org.springframework.context.ConfigurableApplicationContext context)
        指定者:
        initialize 在接口中 org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>