Class GrailsWebApplicationContext

  • All Implemented Interfaces:
    groovy.lang.GroovyObject, java.io.Closeable, java.lang.AutoCloseable, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.core.AliasRegistry, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.ui.context.ThemeSource, org.springframework.web.context.ConfigurableWebApplicationContext, org.springframework.web.context.WebApplicationContext

    public class GrailsWebApplicationContext
    extends org.grails.spring.GrailsApplicationContext
    implements org.springframework.web.context.ConfigurableWebApplicationContext, org.springframework.ui.context.ThemeSource
    A WebApplicationContext that extends StaticApplicationContext to allow for programmatic configuration at runtime. The code is adapted from StaticWebApplicationContext.
    Since:
    0.3
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.springframework.core.io.DefaultResourceLoader

        org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
    • Field Summary

      • Fields inherited from class org.grails.spring.GrailsApplicationContext

        metaClass
      • Fields inherited from class org.springframework.context.support.AbstractApplicationContext

        APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME
      • Fields inherited from interface org.springframework.beans.factory.BeanFactory

        FACTORY_BEAN_PREFIX
      • Fields inherited from interface org.springframework.context.ConfigurableApplicationContext

        APPLICATION_STARTUP_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
      • Fields inherited from interface org.springframework.web.context.ConfigurableWebApplicationContext

        APPLICATION_CONTEXT_ID_PREFIX, SERVLET_CONFIG_BEAN_NAME
      • 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
      • Fields inherited from interface org.springframework.web.context.WebApplicationContext

        CONTEXT_ATTRIBUTES_BEAN_NAME, CONTEXT_PARAMETERS_BEAN_NAME, ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_APPLICATION, SCOPE_REQUEST, SCOPE_SESSION, SERVLET_CONTEXT_BEAN_NAME
    • Constructor Summary

      Constructors 
      Constructor Description
      GrailsWebApplicationContext()  
      GrailsWebApplicationContext​(grails.core.GrailsApplication grailsApplication)  
      GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory)  
      GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory, grails.core.GrailsApplication grailsApplication)  
      GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory, org.springframework.context.ApplicationContext parent)  
      GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory, org.springframework.context.ApplicationContext parent, grails.core.GrailsApplication grailsApplication)  
      GrailsWebApplicationContext​(org.springframework.context.ApplicationContext parent)  
      GrailsWebApplicationContext​(org.springframework.context.ApplicationContext parent, grails.core.GrailsApplication grailsApplication)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.springframework.core.env.ConfigurableEnvironment createEnvironment()  
      java.lang.ClassLoader getClassLoader()  
      java.lang.String[] getConfigLocations()  
      org.springframework.web.context.ConfigurableWebEnvironment getEnvironment()  
      java.lang.String getNamespace()  
      protected org.springframework.core.io.Resource getResourceByPath​(java.lang.String path)
      This implementation supports file paths beneath the root of the ServletContext.
      protected org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()
      This implementation supports pattern matching in unexpanded WARs too.
      javax.servlet.ServletConfig getServletConfig()  
      javax.servlet.ServletContext getServletContext()  
      protected void postProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Register ServletContextAwareProcessor.
      protected void prepareBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)  
      void setConfigLocation​(java.lang.String configLocation)  
      void setConfigLocations​(java.lang.String[] configLocations)  
      void setNamespace​(java.lang.String namespace)  
      void setServletConfig​(javax.servlet.ServletConfig servletConfig)  
      void setServletContext​(javax.servlet.ServletContext servletContext)
      Set the ServletContext that this WebApplicationContext runs in.
      • Methods inherited from class org.grails.spring.GrailsApplicationContext

        assertBeanFactoryActive, containsBeanDefinition, getMetaClass, getProperty, getTheme, invokeMethod, onRefresh, registerPrototype, registerPrototype, registerSingleton, registerSingleton, setMetaClass, setProperty
      • Methods inherited from class org.springframework.context.support.GenericApplicationContext

        cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setApplicationStartup, setClassLoader, setParent, setResourceLoader
      • Methods inherited from class org.springframework.context.support.AbstractApplicationContext

        addApplicationListener, addBeanFactoryPostProcessor, close, containsBean, containsLocalBean, destroy, destroyBeans, doClose, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getApplicationStartup, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setDisplayName, setEnvironment, setId, start, stop, toString
      • Methods inherited from class org.springframework.core.io.DefaultResourceLoader

        addProtocolResolver, clearResourceCaches, getProtocolResolvers, getResourceCache
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.springframework.core.AliasRegistry

        getAliases
      • 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.support.BeanDefinitionRegistry

        getBeanDefinitionCount, getBeanDefinitionNames
      • 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.context.ConfigurableApplicationContext

        addApplicationListener, addBeanFactoryPostProcessor, addProtocolResolver, close, getApplicationStartup, getBeanFactory, isActive, refresh, registerShutdownHook, setApplicationStartup, setClassLoader, setEnvironment, setId, setParent
      • Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory

        containsLocalBean, getParentBeanFactory
      • Methods inherited from interface org.springframework.context.Lifecycle

        isRunning, start, stop
      • Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory

        containsBeanDefinition, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, 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
      • Methods inherited from interface org.springframework.ui.context.ThemeSource

        getTheme
    • Constructor Detail

      • GrailsWebApplicationContext

        public GrailsWebApplicationContext()
                                    throws org.springframework.beans.BeansException
        Throws:
        org.springframework.beans.BeansException
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(grails.core.GrailsApplication grailsApplication)
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.context.ApplicationContext parent)
                                    throws org.springframework.beans.BeansException
        Throws:
        org.springframework.beans.BeansException
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory,
                                           grails.core.GrailsApplication grailsApplication)
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.context.ApplicationContext parent,
                                           grails.core.GrailsApplication grailsApplication)
                                    throws org.springframework.beans.BeansException
        Throws:
        org.springframework.beans.BeansException
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory)
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory,
                                           org.springframework.context.ApplicationContext parent)
      • GrailsWebApplicationContext

        public GrailsWebApplicationContext​(org.springframework.beans.factory.support.DefaultListableBeanFactory defaultListableBeanFactory,
                                           org.springframework.context.ApplicationContext parent,
                                           grails.core.GrailsApplication grailsApplication)
    • Method Detail

      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Specified by:
        getClassLoader in interface org.springframework.core.io.ResourceLoader
        Overrides:
        getClassLoader in class org.springframework.context.support.GenericApplicationContext
      • setServletContext

        public void setServletContext​(javax.servlet.ServletContext servletContext)
        Set the ServletContext that this WebApplicationContext runs in.
        Specified by:
        setServletContext in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • getServletContext

        public javax.servlet.ServletContext getServletContext()
        Specified by:
        getServletContext in interface org.springframework.web.context.WebApplicationContext
      • setNamespace

        public void setNamespace​(java.lang.String namespace)
        Specified by:
        setNamespace in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • getNamespace

        public java.lang.String getNamespace()
        Specified by:
        getNamespace in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • setConfigLocation

        public void setConfigLocation​(java.lang.String configLocation)
        Specified by:
        setConfigLocation in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • setConfigLocations

        public void setConfigLocations​(java.lang.String[] configLocations)
        Specified by:
        setConfigLocations in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • getConfigLocations

        public java.lang.String[] getConfigLocations()
        Specified by:
        getConfigLocations in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • postProcessBeanFactory

        protected void postProcessBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
        Register ServletContextAwareProcessor.
        Overrides:
        postProcessBeanFactory in class org.springframework.context.support.AbstractApplicationContext
        See Also:
        ServletContextAwareProcessor
      • getResourceByPath

        protected org.springframework.core.io.Resource getResourceByPath​(java.lang.String path)
        This implementation supports file paths beneath the root of the ServletContext.
        Overrides:
        getResourceByPath in class org.springframework.core.io.DefaultResourceLoader
        See Also:
        ServletContextResource
      • getResourcePatternResolver

        protected org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()
        This implementation supports pattern matching in unexpanded WARs too.
        Overrides:
        getResourcePatternResolver in class org.springframework.context.support.AbstractApplicationContext
        See Also:
        ServletContextResourcePatternResolver
      • prepareBeanFactory

        protected void prepareBeanFactory​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
        Overrides:
        prepareBeanFactory in class org.grails.spring.GrailsApplicationContext
      • setServletConfig

        public void setServletConfig​(javax.servlet.ServletConfig servletConfig)
        Specified by:
        setServletConfig in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • getServletConfig

        public javax.servlet.ServletConfig getServletConfig()
        Specified by:
        getServletConfig in interface org.springframework.web.context.ConfigurableWebApplicationContext
      • createEnvironment

        protected org.springframework.core.env.ConfigurableEnvironment createEnvironment()
        Overrides:
        createEnvironment in class org.springframework.context.support.AbstractApplicationContext
      • getEnvironment

        public org.springframework.web.context.ConfigurableWebEnvironment getEnvironment()
        Specified by:
        getEnvironment in interface org.springframework.context.ConfigurableApplicationContext
        Specified by:
        getEnvironment in interface org.springframework.core.env.EnvironmentCapable
        Overrides:
        getEnvironment in class org.springframework.context.support.AbstractApplicationContext