Interface CockpitApplicationContext

  • All Superinterfaces:
    org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.beans.factory.BeanFactory, org.springframework.core.env.EnvironmentCapable, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.context.MessageSource, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver
    All Known Implementing Classes:
    DefaultDelegatingCockpitApplicationContext

    public interface CockpitApplicationContext
    extends org.springframework.context.ApplicationContext
    An application context providing CockpitNG features.

    CockpitNG-based applications should be run using an application context implementing this interface. It also should be a context available under org.springframework.web.context.WebApplicationContext.ROOT attribute in servlet context.

    • 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 Abstract Methods 
      Modifier and Type Method Description
      CockpitClassLoader getClassLoader()
      Retrieves a class loader aware of all fetched modules
      static CockpitApplicationContext getCockpitApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
      Extracts the cockpit application context out of the provided one
      java.io.File getDataRootDir()
      Retrieves a root directory for all the application data
      java.util.List<java.lang.String> getLoadedModulesNames()
      Retrieves a collection of names all the loaded modules.
      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
      boolean isReady()  
      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 interface org.springframework.context.ApplicationContext

        getApplicationName, getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate
      • Methods inherited from interface org.springframework.context.ApplicationEventPublisher

        publishEvent, publishEvent
      • Methods inherited from interface org.springframework.beans.factory.BeanFactory

        containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch
      • Methods inherited from interface org.springframework.core.env.EnvironmentCapable

        getEnvironment
      • Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory

        containsLocalBean, getParentBeanFactory
      • Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory

        containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation
      • Methods inherited from interface org.springframework.context.MessageSource

        getMessage, getMessage, getMessage
      • Methods inherited from interface org.springframework.core.io.ResourceLoader

        getResource
      • Methods inherited from interface org.springframework.core.io.support.ResourcePatternResolver

        getResources
    • Method Detail

      • getCockpitApplicationContext

        static CockpitApplicationContext getCockpitApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
        Extracts the cockpit application context out of the provided one
        Parameters:
        applicationContext - base application context
        Returns:
        cockpit application context
        Throws:
        org.springframework.beans.FatalBeanException - if the cockpit application context cannot be extracted
      • getDataRootDir

        java.io.File getDataRootDir()
        Retrieves a root directory for all the application data
        Returns:
        root directory for application data
      • getLoadedModulesNames

        java.util.List<java.lang.String> getLoadedModulesNames()
        Retrieves a collection of names all the loaded modules.

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

        Returns:
        names of modules
      • getModuleName

        java.util.Optional<java.lang.String> getModuleName​(java.net.URI moduleURI)
        Returns a fetched module name
        Parameters:
        moduleURI - URI to module source
        Returns:
        module name
      • getModuleURI

        java.util.Optional<java.net.URI> getModuleURI​(java.lang.String moduleName)
        Retrieves a URI to source of module
        Parameters:
        moduleName - name of module
        Returns:
        source URI
      • getModuleInfo

        java.util.Optional<ModuleInfo> getModuleInfo​(java.lang.String moduleName)
        Retrieves information about module
        Parameters:
        moduleName - module name
        Returns:
        information about module
        See Also:
        getLoadedModulesNames()
      • registerNewModule

        void registerNewModule​(java.lang.String moduleName,
                               ModuleContentProvider contentsProvider)
                        throws CockpitApplicationException
        Creates a new module library, if it does not exist already. The library is automatically added to application context after consumed.
        Parameters:
        moduleName - name of the module for which a library will be registered
        contentsProvider - functional object capable of providing contents for the library
        Throws:
        CockpitApplicationException
      • unregisterModule

        void unregisterModule​(java.lang.String moduleName)
                       throws CockpitApplicationException
        Removes a module library if such exists. The library is automatically removed from application context.
        Parameters:
        moduleName - name of the module for which the library will be unregistered
        Throws:
        CockpitApplicationException
      • getClassLoader

        CockpitClassLoader getClassLoader()
        Retrieves a class loader aware of all fetched modules
        Specified by:
        getClassLoader in interface org.springframework.core.io.ResourceLoader
        Returns:
        class loader
      • refresh

        void refresh()
        Reloads all modules and beans
        Throws:
        org.springframework.beans.BeansException - if any problems with context refresh has occurred
      • isReady

        boolean isReady()
        Returns: