|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.springframework.web.portlet.context.PortletContextLoader
public class PortletContextLoader
Performs the actual initialization work for the root application context.
Called by PortletContextLoaderListener.
Looks for a "portletContextClass" context-param
at the web.xml level to specify the context
class type, falling back to the default of
ContribXmlPortletApplicationContext
if not found. With the default PortletContextLoader implementation, any context class
specified needs to implement the ConfigurablePortletApplicationContext interface.
Processes a "portletContextConfigLocation"
context-param at the web.xml level and passes its value to the context instance, parsing it into
potentially multiple file paths which can be separated by any number of
commas and spaces, e.g. "WEB-INF/portletApplicationContext1.xml,
WEB-INF/portletApplicationContext2.xml". Ant-style path patterns are supported as well,
e.g. "WEB-INF/portlet*Context.xml,WEB-INF/springPortlet*.xml" or "WEB-INF/**/portlet*Context.xml".
If not explicitly specified, the context implementation is supposed to use a
default location (with ContribXmlPortletApplicationContext: "/WEB-INF/portletApplicationContext.xml").
Note: In case of multiple config locations, later bean definitions will override ones defined in previously loaded files, at least when using one of Spring's default ApplicationContext implementations. This can be leveraged to deliberately override certain bean definitions via an extra XML file.
Above and beyond loading the root portlet application context, this class
can optionally load or obtain and hook up a shared parent context to
the root application context. See the
loadParentContext(PortletContext) method for more information.
PortletContextLoaderListener,
PortletApplicationContext,
XmlPortletApplicationContext| Field Summary | |
|---|---|
static String |
CONFIG_LOCATION_PARAM
Name of portlet context parameter (i.e., "portletContextConfigLocation") that can specify the config location for the root context, falling back to the implementation's default otherwise. |
static String |
CONTEXT_CLASS_PARAM
Config param for the root PortletApplicationContext implementation class to use: "portletContextClass" |
static String |
CONTEXT_ID_PARAM
Config param for the root PortletApplicationContext id, to be used as serialization id for the underlying BeanFactory: "portletContextId" |
static String |
CONTEXT_INITIALIZER_CLASSES_PARAM
Config param for which ApplicationContextInitializer classes to use
for initializing the web application context: "portletContextInitializerClasses" |
| Constructor Summary | |
|---|---|
PortletContextLoader(javax.servlet.ServletContext servletContext)
|
|
| Method Summary | |
|---|---|
void |
closeWebApplicationContext(javax.servlet.ServletContext servletContext)
Close Spring's web application context for the given portlet context. |
protected void |
configureAndRefreshPortletApplicationContext(org.springframework.web.portlet.context.ConfigurablePortletApplicationContext pac,
javax.portlet.PortletContext pc)
|
protected PortletApplicationContext |
createPortletApplicationContext(javax.portlet.PortletContext sc)
Instantiate the root PortletApplicationContext for this loader, either the default context class or a custom context class if specified. |
protected void |
customizeContext(javax.portlet.PortletContext portletContext,
org.springframework.web.portlet.context.ConfigurablePortletApplicationContext applicationContext)
Customize the ConfigurablePortletApplicationContext created by this
PortletContextLoader after config locations have been supplied to the context
but before the context is refreshed. |
protected Class<?> |
determineContextClass(javax.portlet.PortletContext portletContext)
Return the PortletApplicationContext implementation class to use, either the default XmlPortletApplicationContext or a custom context class if specified. |
protected List<Class<org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>>> |
determineContextInitializerClasses(javax.portlet.PortletContext portletContext)
Return the ApplicationContextInitializer implementation classes to use
if any have been specified by CONTEXT_INITIALIZER_CLASSES_PARAM. |
static PortletApplicationContext |
getCurrentPortletApplicationContext()
Obtain the Spring root portlet application context for the current thread (i.e. |
PortletApplicationContext |
initWebApplicationContext(javax.portlet.PortletContext portletContext)
Initialize Spring's portlet application context for the given portlet context, using the application context provided at construction time, or creating a new one according to the " contextClass" and
"contextConfigLocation" context-params. |
protected org.springframework.context.ApplicationContext |
loadParentContext(javax.portlet.PortletContext portletContext)
Template method with default implementation (which may be overridden by a subclass), to load or obtain an ApplicationContext instance which will be used as the parent context of the root PortletApplicationContext. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CONTEXT_CLASS_PARAM
PortletApplicationContext implementation class to use: "portletContextClass"
determineContextClass(PortletContext),
#createWebApplicationContext(PortletContext, ApplicationContext),
Constant Field Valuespublic static final String CONTEXT_ID_PARAM
public static final String CONTEXT_INITIALIZER_CLASSES_PARAM
ApplicationContextInitializer classes to use
for initializing the web application context: "portletContextInitializerClasses"
customizeContext(PortletContext, ConfigurablePortletApplicationContext),
Constant Field Valuespublic static final String CONFIG_LOCATION_PARAM
XmlPortletApplicationContext.DEFAULT_CONFIG_LOCATION,
Constant Field Values| Constructor Detail |
|---|
public PortletContextLoader(javax.servlet.ServletContext servletContext)
| Method Detail |
|---|
public PortletApplicationContext initWebApplicationContext(javax.portlet.PortletContext portletContext)
contextClass" and
"contextConfigLocation" context-params.
portletContext - current portlet context
CONTEXT_CLASS_PARAM,
CONFIG_LOCATION_PARAMprotected PortletApplicationContext createPortletApplicationContext(javax.portlet.PortletContext sc)
This implementation expects custom contexts to implement the
ConfigurablePortletApplicationContext interface.
Can be overridden in subclasses.
In addition, customizeContext(javax.portlet.PortletContext, org.springframework.web.portlet.context.ConfigurablePortletApplicationContext) gets called prior to refreshing the
context, allowing subclasses to perform custom modifications to the context.
sc - current portlet context
ConfigurablePortletApplicationContext
protected void configureAndRefreshPortletApplicationContext(org.springframework.web.portlet.context.ConfigurablePortletApplicationContext pac,
javax.portlet.PortletContext pc)
protected Class<?> determineContextClass(javax.portlet.PortletContext portletContext)
portletContext - current portlet context
CONTEXT_CLASS_PARAM,
XmlPortletApplicationContextprotected List<Class<org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>>> determineContextInitializerClasses(javax.portlet.PortletContext portletContext)
ApplicationContextInitializer implementation classes to use
if any have been specified by CONTEXT_INITIALIZER_CLASSES_PARAM.
portletContext - current portlet contextCONTEXT_INITIALIZER_CLASSES_PARAM
protected void customizeContext(javax.portlet.PortletContext portletContext,
org.springframework.web.portlet.context.ConfigurablePortletApplicationContext applicationContext)
ConfigurablePortletApplicationContext created by this
PortletContextLoader after config locations have been supplied to the context
but before the context is refreshed.
The default implementation determines what (if any) context initializer classes have been specified through context init parameters and invokes each with the given web application context.
Any ApplicationContextInitializers implementing
Ordered or marked with @Order will be sorted appropriately.
portletContext - the current portlet contextapplicationContext - the newly created application contextcreatePortletApplicationContext(PortletContext),
CONTEXT_INITIALIZER_CLASSES_PARAM,
ApplicationContextInitializer.initialize(ConfigurableApplicationContext)protected org.springframework.context.ApplicationContext loadParentContext(javax.portlet.PortletContext portletContext)
The default implementation uses
PortletApplicationContextUtils.getWebApplicationContext(PortletContext)
to load a parent context.
portletContext - current portlet context
null if nonepublic void closeWebApplicationContext(javax.servlet.ServletContext servletContext)
loadParentContext(PortletContext) implementation,
which uses ContextSingletonBeanFactoryLocator, has loaded any shared
parent context, release one reference to that shared parent context.
If overriding loadParentContext(PortletContext), you may have
to override this method as well.
servletContext - the PortletContext that the WebApplicationContext runs inpublic static PortletApplicationContext getCurrentPortletApplicationContext()
null
if none foundorg.springframework.web.context.support.SpringBeanAutowiringSupport
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||