public abstract class

AbstractRefreshablePortletApplicationContext

extends AbstractRefreshableConfigApplicationContext
implements WebApplicationContext ConfigurablePortletApplicationContext
java.lang.Object
   ↳ org.springframework.core.io.DefaultResourceLoader
     ↳ org.springframework.context.support.AbstractApplicationContext
       ↳ org.springframework.context.support.AbstractRefreshableApplicationContext
         ↳ org.springframework.context.support.AbstractRefreshableConfigApplicationContext
           ↳ org.springframework.web.portlet.context.AbstractRefreshablePortletApplicationContext
Known Direct Subclasses

Class Overview

AbstractRefreshableApplicationContext subclass which implements the ConfigurablePortletApplicationContext interface for portlet environments. Provides a "configLocations" property, to be populated through the ConfigurablePortletApplicationContext interface on portlet application startup.

This class is as easy to subclass as AbstractRefreshableApplicationContext: All you need to implements is the loadBeanDefinitions(DefaultListableBeanFactory) method; see the superclass javadoc for details. Note that implementations are supposed to load bean definitions from the files specified by the locations returned by the getConfigLocations() method.

Interprets resource paths as servlet context resources, i.e. as paths beneath the web application root. Absolute paths, e.g. for files outside the web app root, can be accessed via "file:" URLs, as implemented by DefaultResourceLoader.

This is the portlet context to be subclassed for a different bean definition format. Such a context implementation can be specified as "contextClass" init-param for FrameworkPortlet, replacing the default XmlPortletApplicationContext. It will then automatically receive the "contextConfigLocation" init-param.

Note that Portlet-based context implementations are generally supposed to configure themselves based on the configuration received through the ConfigurablePortletApplicationContext interface. In contrast, a standalone application context might allow for configuration in custom startup code (for example, GenericApplicationContext).

Summary

[Expand]
Inherited Constants
From class org.springframework.context.support.AbstractApplicationContext
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver
From interface org.springframework.web.context.WebApplicationContext
From interface org.springframework.web.portlet.context.ConfigurablePortletApplicationContext
[Expand]
Inherited Fields
From class org.springframework.context.support.AbstractApplicationContext
From interface org.springframework.web.context.WebApplicationContext
From interface org.springframework.web.portlet.context.ConfigurablePortletApplicationContext
Public Constructors
AbstractRefreshablePortletApplicationContext()
Public Methods
String[] getConfigLocations()
Return an array of resource locations, referring to the XML bean definition files that this context should be built with.
String getNamespace()
Return the namespace for this web application context, if any.
PortletConfig getPortletConfig()
Return the PortletConfig for this portlet application context, if any.
PortletContext getPortletContext()
Return the standard Portlet API PortletContext for this application.
ServletContext getServletContext()
Return the standard Servlet API ServletContext for this application.
void setNamespace(String namespace)
Set the namespace for this portlet application context, to be used for building a default context config location.
void setParent(ApplicationContext parent)
Set the parent of this application context.
void setPortletConfig(PortletConfig portletConfig)
Set the PortletConfig for this portlet application context.
void setPortletContext(PortletContext portletContext)
Set the PortletContext for this portlet application context.
Protected Methods
ConfigurableEnvironment createEnvironment()
Create and return a new DefaultPortletEnvironment.
void customizeBeanFactory(DefaultListableBeanFactory beanFactory)
Customize the internal bean factory used by this context.
Resource getResourceByPath(String path)
This implementation supports file paths beneath the root of the PortletContext.
ResourcePatternResolver getResourcePatternResolver()
This implementation supports pattern matching in unexpanded WARs too.
void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Register request/session scopes, a PortletContextAwareProcessor, etc.
[Expand]
Inherited Methods
From class org.springframework.context.support.AbstractRefreshableConfigApplicationContext
From class org.springframework.context.support.AbstractRefreshableApplicationContext
From class org.springframework.context.support.AbstractApplicationContext
From class org.springframework.core.io.DefaultResourceLoader
From class java.lang.Object
From interface org.springframework.beans.factory.BeanFactory
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.HierarchicalBeanFactory
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.beans.factory.ListableBeanFactory
From interface org.springframework.context.ApplicationContext
From interface org.springframework.context.ApplicationEventPublisher
From interface org.springframework.context.ConfigurableApplicationContext
From interface org.springframework.context.Lifecycle
From interface org.springframework.context.MessageSource
From interface org.springframework.core.env.EnvironmentCapable
From interface org.springframework.core.io.ResourceLoader
From interface org.springframework.core.io.support.ResourcePatternResolver
From interface org.springframework.web.context.WebApplicationContext
From interface org.springframework.web.portlet.context.ConfigurablePortletApplicationContext

Public Constructors

public AbstractRefreshablePortletApplicationContext ()

Public Methods

public String[] getConfigLocations ()

Return an array of resource locations, referring to the XML bean definition files that this context should be built with. Can also include location patterns, which will get resolved via a ResourcePatternResolver.

The default implementation returns null. Subclasses can override this to provide a set of resource locations to load bean definitions from.

Returns
  • an array of resource locations, or null if none

public String getNamespace ()

Return the namespace for this web application context, if any.

public PortletConfig getPortletConfig ()

Return the PortletConfig for this portlet application context, if any.

public PortletContext getPortletContext ()

Return the standard Portlet API PortletContext for this application.

public ServletContext getServletContext ()

Return the standard Servlet API ServletContext for this application.

Also available for a Portlet application, in addition to the PortletContext.

public void setNamespace (String namespace)

Set the namespace for this portlet application context, to be used for building a default context config location.

public void setParent (ApplicationContext parent)

Set the parent of this application context.

Note that the parent shouldn't be changed: It should only be set outside a constructor if it isn't available when an object of this class is created, for example in case of WebApplicationContext setup.

Parameters
parent the parent context

public void setPortletConfig (PortletConfig portletConfig)

Set the PortletConfig for this portlet application context.

public void setPortletContext (PortletContext portletContext)

Set the PortletContext for this portlet application context.

Does not cause an initialization of the context: refresh needs to be called after the setting of all configuration properties.

Protected Methods

protected ConfigurableEnvironment createEnvironment ()

Create and return a new DefaultPortletEnvironment.

protected void customizeBeanFactory (DefaultListableBeanFactory beanFactory)

Customize the internal bean factory used by this context. Called for each refresh() attempt.

The default implementation applies this context's "allowBeanDefinitionOverriding" and "allowCircularReferences" settings, if specified. Can be overridden in subclasses to customize any of DefaultListableBeanFactory's settings.

Parameters
beanFactory the newly created bean factory for this context

protected Resource getResourceByPath (String path)

This implementation supports file paths beneath the root of the PortletContext.

Parameters
path the path to the resource
Returns
  • the corresponding Resource handle

protected ResourcePatternResolver getResourcePatternResolver ()

This implementation supports pattern matching in unexpanded WARs too.

Returns
  • the ResourcePatternResolver for this context

protected void postProcessBeanFactory (ConfigurableListableBeanFactory beanFactory)

Register request/session scopes, a PortletContextAwareProcessor, etc.

Parameters
beanFactory the bean factory used by the application context