Class DefaultDelegatingCockpitApplicationContext

  • All Implemented Interfaces:
    CockpitApplicationContext, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.context.MessageSource, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

    public class DefaultDelegatingCockpitApplicationContext
    extends java.lang.Object
    implements CockpitApplicationContext
    A fallback CockpitApplicationContext that delegates all calls to methods known to specified standard ApplicationContext and tries to figure out the result of call to methods unknown to standard one.
    • Field Summary

      • Fields inherited from interface org.springframework.beans.factory.BeanFactory

        FACTORY_BEAN_PREFIX
      • Fields inherited from interface org.springframework.core.io.ResourceLoader

        CLASSPATH_URL_PREFIX
      • Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver

        CLASSPATH_ALL_URL_PREFIX
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsBean​(java.lang.String s)  
      boolean containsBeanDefinition​(java.lang.String s)  
      boolean containsLocalBean​(java.lang.String s)  
      <A extends java.lang.annotation.Annotation>
      A
      findAnnotationOnBean​(java.lang.String s, java.lang.Class<A> aClass)  
      java.lang.String[] getAliases​(java.lang.String s)  
      java.lang.String getApplicationName()  
      org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()  
      <T> T getBean​(java.lang.Class<T> aClass)  
      <T> T getBean​(java.lang.Class<T> aClass, java.lang.Object... objects)  
      java.lang.Object getBean​(java.lang.String s)  
      <T> T getBean​(java.lang.String s, java.lang.Class<T> aClass)  
      java.lang.Object getBean​(java.lang.String s, java.lang.Object... objects)  
      int getBeanDefinitionCount()  
      java.lang.String[] getBeanDefinitionNames()  
      java.lang.String[] getBeanNamesForAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)  
      java.lang.String[] getBeanNamesForType​(java.lang.Class<?> aClass)  
      java.lang.String[] getBeanNamesForType​(java.lang.Class<?> aClass, boolean b, boolean b1)  
      java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType resolvableType)  
      java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit)  
      <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(java.lang.Class<T> aClass)  
      <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(org.springframework.core.ResolvableType resolvableType)  
      <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> aClass)  
      <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> aClass, boolean b, boolean b1)  
      java.util.Map<java.lang.String,​java.lang.Object> getBeansWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)  
      CockpitClassLoader getClassLoader()
      Retrieves a class loader aware of all fetched modules
      java.io.File getDataRootDir()
      Retrieves a root directory for all the application data
      java.lang.String getDisplayName()  
      org.springframework.core.env.Environment getEnvironment()  
      java.lang.String getId()  
      static DefaultDelegatingCockpitApplicationContext getInstance​(org.springframework.context.ApplicationContext applicationContext)
      Wraps provided application context with delegating one if needed.
      java.util.List<java.lang.String> getLoadedModulesNames()
      Retrieves a collection of names all the loaded modules.
      java.lang.String getMessage​(java.lang.String s, java.lang.Object[] objects, java.lang.String s1, java.util.Locale locale)  
      java.lang.String getMessage​(java.lang.String s, java.lang.Object[] objects, java.util.Locale locale)  
      java.lang.String getMessage​(org.springframework.context.MessageSourceResolvable messageSourceResolvable, java.util.Locale locale)  
      java.util.Optional<ModuleInfo> getModuleInfo​(java.lang.String moduleName)
      Retrieves information about module
      java.util.Optional<java.lang.String> getModuleName​(java.net.URI moduleURI)
      Returns a fetched module name
      java.util.Optional<java.net.URI> getModuleURI​(java.lang.String moduleName)
      Retrieves a URI to source of module
      org.springframework.context.ApplicationContext getParent()  
      org.springframework.beans.factory.BeanFactory getParentBeanFactory()  
      org.springframework.core.io.Resource getResource​(java.lang.String s)  
      org.springframework.core.io.Resource[] getResources​(java.lang.String s)  
      long getStartupDate()  
      java.lang.Class<?> getType​(java.lang.String s)  
      java.lang.Class<?> getType​(java.lang.String name, boolean allowFactoryBeanInit)  
      boolean isPrototype​(java.lang.String s)  
      boolean isReady()  
      boolean isSingleton​(java.lang.String s)  
      boolean isTypeMatch​(java.lang.String s, java.lang.Class<?> aClass)  
      boolean isTypeMatch​(java.lang.String s, org.springframework.core.ResolvableType resolvableType)  
      void publishEvent​(java.lang.Object o)  
      void publishEvent​(org.springframework.context.ApplicationEvent applicationEvent)  
      void refresh()
      Reloads all modules and beans
      void registerNewModule​(java.lang.String moduleName, ModuleContentProvider contentsProvider)
      Creates a new module library, if it does not exist already.
      void unregisterModule​(java.lang.String moduleName)
      Removes a module library if such exists.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static DefaultDelegatingCockpitApplicationContext getInstance​(org.springframework.context.ApplicationContext applicationContext)
        Wraps provided application context with delegating one if needed.
        Parameters:
        applicationContext - application context to be wrapped
        Returns:
        wrapped application context
      • getId

        public java.lang.String getId()
        Specified by:
        getId in interface org.springframework.context.ApplicationContext
      • getApplicationName

        public java.lang.String getApplicationName()
        Specified by:
        getApplicationName in interface org.springframework.context.ApplicationContext
      • getDisplayName

        public java.lang.String getDisplayName()
        Specified by:
        getDisplayName in interface org.springframework.context.ApplicationContext
      • getStartupDate

        public long getStartupDate()
        Specified by:
        getStartupDate in interface org.springframework.context.ApplicationContext
      • getParent

        public org.springframework.context.ApplicationContext getParent()
        Specified by:
        getParent in interface org.springframework.context.ApplicationContext
      • getAutowireCapableBeanFactory

        public org.springframework.beans.factory.config.AutowireCapableBeanFactory getAutowireCapableBeanFactory()
        Specified by:
        getAutowireCapableBeanFactory in interface org.springframework.context.ApplicationContext
      • getEnvironment

        public org.springframework.core.env.Environment getEnvironment()
        Specified by:
        getEnvironment in interface org.springframework.core.env.EnvironmentCapable
      • containsBeanDefinition

        public boolean containsBeanDefinition​(java.lang.String s)
        Specified by:
        containsBeanDefinition in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanDefinitionCount

        public int getBeanDefinitionCount()
        Specified by:
        getBeanDefinitionCount in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanDefinitionNames

        public java.lang.String[] getBeanDefinitionNames()
        Specified by:
        getBeanDefinitionNames in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanNamesForType

        public java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType resolvableType)
        Specified by:
        getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanNamesForType

        public java.lang.String[] getBeanNamesForType​(org.springframework.core.ResolvableType type,
                                                      boolean includeNonSingletons,
                                                      boolean allowEagerInit)
        Specified by:
        getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanNamesForType

        public java.lang.String[] getBeanNamesForType​(java.lang.Class<?> aClass)
        Specified by:
        getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanNamesForType

        public java.lang.String[] getBeanNamesForType​(java.lang.Class<?> aClass,
                                                      boolean b,
                                                      boolean b1)
        Specified by:
        getBeanNamesForType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeansOfType

        public <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> aClass)
        Specified by:
        getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeansOfType

        public <T> java.util.Map<java.lang.String,​T> getBeansOfType​(java.lang.Class<T> aClass,
                                                                          boolean b,
                                                                          boolean b1)
        Specified by:
        getBeansOfType in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeanNamesForAnnotation

        public java.lang.String[] getBeanNamesForAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)
        Specified by:
        getBeanNamesForAnnotation in interface org.springframework.beans.factory.ListableBeanFactory
      • getBeansWithAnnotation

        public java.util.Map<java.lang.String,​java.lang.Object> getBeansWithAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> aClass)
        Specified by:
        getBeansWithAnnotation in interface org.springframework.beans.factory.ListableBeanFactory
      • findAnnotationOnBean

        public <A extends java.lang.annotation.Annotation> A findAnnotationOnBean​(java.lang.String s,
                                                                                  java.lang.Class<A> aClass)
                                                                           throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        Specified by:
        findAnnotationOnBean in interface org.springframework.beans.factory.ListableBeanFactory
        Throws:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • getBean

        public java.lang.Object getBean​(java.lang.String s)
        Specified by:
        getBean in interface org.springframework.beans.factory.BeanFactory
      • getBean

        public <T> T getBean​(java.lang.String s,
                             java.lang.Class<T> aClass)
        Specified by:
        getBean in interface org.springframework.beans.factory.BeanFactory
      • getBean

        public java.lang.Object getBean​(java.lang.String s,
                                        java.lang.Object... objects)
        Specified by:
        getBean in interface org.springframework.beans.factory.BeanFactory
      • getBean

        public <T> T getBean​(java.lang.Class<T> aClass)
        Specified by:
        getBean in interface org.springframework.beans.factory.BeanFactory
      • getBean

        public <T> T getBean​(java.lang.Class<T> aClass,
                             java.lang.Object... objects)
        Specified by:
        getBean in interface org.springframework.beans.factory.BeanFactory
      • getBeanProvider

        public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(java.lang.Class<T> aClass)
        Specified by:
        getBeanProvider in interface org.springframework.beans.factory.BeanFactory
      • getBeanProvider

        public <T> org.springframework.beans.factory.ObjectProvider<T> getBeanProvider​(org.springframework.core.ResolvableType resolvableType)
        Specified by:
        getBeanProvider in interface org.springframework.beans.factory.BeanFactory
      • containsBean

        public boolean containsBean​(java.lang.String s)
        Specified by:
        containsBean in interface org.springframework.beans.factory.BeanFactory
      • isSingleton

        public boolean isSingleton​(java.lang.String s)
        Specified by:
        isSingleton in interface org.springframework.beans.factory.BeanFactory
      • isPrototype

        public boolean isPrototype​(java.lang.String s)
        Specified by:
        isPrototype in interface org.springframework.beans.factory.BeanFactory
      • isTypeMatch

        public boolean isTypeMatch​(java.lang.String s,
                                   org.springframework.core.ResolvableType resolvableType)
        Specified by:
        isTypeMatch in interface org.springframework.beans.factory.BeanFactory
      • isTypeMatch

        public boolean isTypeMatch​(java.lang.String s,
                                   java.lang.Class<?> aClass)
        Specified by:
        isTypeMatch in interface org.springframework.beans.factory.BeanFactory
      • getType

        public java.lang.Class<?> getType​(java.lang.String s)
        Specified by:
        getType in interface org.springframework.beans.factory.BeanFactory
      • getType

        public java.lang.Class<?> getType​(java.lang.String name,
                                          boolean allowFactoryBeanInit)
                                   throws org.springframework.beans.factory.NoSuchBeanDefinitionException
        Specified by:
        getType in interface org.springframework.beans.factory.BeanFactory
        Throws:
        org.springframework.beans.factory.NoSuchBeanDefinitionException
      • getAliases

        public java.lang.String[] getAliases​(java.lang.String s)
        Specified by:
        getAliases in interface org.springframework.beans.factory.BeanFactory
      • getParentBeanFactory

        public org.springframework.beans.factory.BeanFactory getParentBeanFactory()
        Specified by:
        getParentBeanFactory in interface org.springframework.beans.factory.HierarchicalBeanFactory
      • containsLocalBean

        public boolean containsLocalBean​(java.lang.String s)
        Specified by:
        containsLocalBean in interface org.springframework.beans.factory.HierarchicalBeanFactory
      • getMessage

        public java.lang.String getMessage​(java.lang.String s,
                                           java.lang.Object[] objects,
                                           java.lang.String s1,
                                           java.util.Locale locale)
        Specified by:
        getMessage in interface org.springframework.context.MessageSource
      • getMessage

        public java.lang.String getMessage​(java.lang.String s,
                                           java.lang.Object[] objects,
                                           java.util.Locale locale)
        Specified by:
        getMessage in interface org.springframework.context.MessageSource
      • getMessage

        public java.lang.String getMessage​(org.springframework.context.MessageSourceResolvable messageSourceResolvable,
                                           java.util.Locale locale)
        Specified by:
        getMessage in interface org.springframework.context.MessageSource
      • publishEvent

        public void publishEvent​(org.springframework.context.ApplicationEvent applicationEvent)
        Specified by:
        publishEvent in interface org.springframework.context.ApplicationEventPublisher
      • publishEvent

        public void publishEvent​(java.lang.Object o)
        Specified by:
        publishEvent in interface org.springframework.context.ApplicationEventPublisher
      • getResources

        public org.springframework.core.io.Resource[] getResources​(java.lang.String s)
                                                            throws java.io.IOException
        Specified by:
        getResources in interface org.springframework.core.io.support.ResourcePatternResolver
        Throws:
        java.io.IOException
      • getResource

        public org.springframework.core.io.Resource getResource​(java.lang.String s)
        Specified by:
        getResource in interface org.springframework.core.io.ResourceLoader
      • refresh

        public void refresh()
                     throws org.springframework.beans.BeansException
        Description copied from interface: CockpitApplicationContext
        Reloads all modules and beans
        Specified by:
        refresh in interface CockpitApplicationContext
        Throws:
        org.springframework.beans.BeansException - if any problems with context refresh has occurred
      • getLoadedModulesNames

        public java.util.List<java.lang.String> getLoadedModulesNames()
        Description copied from interface: CockpitApplicationContext
        Retrieves a collection of names all the loaded modules.

        List should contain only unique values in same order that modules has been loaded.

        Specified by:
        getLoadedModulesNames in interface CockpitApplicationContext
        Returns:
        names of modules
      • getModuleName

        public java.util.Optional<java.lang.String> getModuleName​(java.net.URI moduleURI)
        Description copied from interface: CockpitApplicationContext
        Returns a fetched module name
        Specified by:
        getModuleName in interface CockpitApplicationContext
        Parameters:
        moduleURI - URI to module source
        Returns:
        module name
      • getModuleURI

        public java.util.Optional<java.net.URI> getModuleURI​(java.lang.String moduleName)
        Description copied from interface: CockpitApplicationContext
        Retrieves a URI to source of module
        Specified by:
        getModuleURI in interface CockpitApplicationContext
        Parameters:
        moduleName - name of module
        Returns:
        source URI