类 PortletApplicationContextUtils
- java.lang.Object
- org.springframework.web.portlet.context.PortletApplicationContextUtils
public abstract class PortletApplicationContextUtils extends Object
Convenience methods for retrieving the rootWebApplicationContextfor a givenPortletContext. This is useful for programmatically accessing a Spring application context from within custom Portlet implementations.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, John A. Lewis
- 另请参阅:
ContextLoader,WebApplicationContextUtils,FrameworkPortlet,DispatcherPortlet
构造器概要
构造器 构造器 说明 PortletApplicationContextUtils()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static ApplicationContextgetRequiredWebApplicationContext(PortletContext pc)Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.static ApplicationContextgetWebApplicationContext(PortletContext pc)Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.static voidinitPortletPropertySources(MutablePropertySources propertySources, ServletContext servletContext, PortletContext portletContext, PortletConfig portletConfig)ReplaceServlet- andPortlet-basedstub property sourceswith actual instances populated with the givenservletContext,portletContextandportletConfigobjects.
构造器详细资料
PortletApplicationContextUtils
public PortletApplicationContextUtils()
方法详细资料
getWebApplicationContext
public static ApplicationContext getWebApplicationContext(PortletContext pc)
Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- 参数:
pc- PortletContext to find the web application context for- 返回:
- the root WebApplicationContext for this web app, or
nullif none (typed to ApplicationContext to avoid a Servlet API dependency; can usually be casted to WebApplicationContext, but there shouldn't be a need to) - 另请参阅:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
getRequiredWebApplicationContext
public static ApplicationContext getRequiredWebApplicationContext(PortletContext pc) throws IllegalStateException
Find the rootWebApplicationContextfor this web app, typically loaded viaContextLoaderListener.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- 参数:
pc- PortletContext to find the web application context for- 返回:
- the root WebApplicationContext for this web app (typed to ApplicationContext to avoid a Servlet API dependency; can usually be casted to WebApplicationContext, but there shouldn't be a need to)
- 抛出:
IllegalStateException- if the root WebApplicationContext could not be found- 另请参阅:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
initPortletPropertySources
public static void initPortletPropertySources(MutablePropertySources propertySources, ServletContext servletContext, PortletContext portletContext, PortletConfig portletConfig)
ReplaceServlet- andPortlet-basedstub property sourceswith actual instances populated with the givenservletContext,portletContextandportletConfigobjects.This method is idempotent with respect to the fact it may be called any number of times but will perform replacement of stub property sources with their corresponding actual property sources once and only once.
- 参数:
propertySources- theMutablePropertySourcesto initialize (must not benull)servletContext- the currentServletContext(ignored ifnullor if theservlet context property sourcehas already been initialized)portletContext- the currentPortletContext(ignored ifnullor if theportlet context property sourcehas already been initialized)portletConfig- the currentPortletConfig(ignored ifnullor if theportlet config property sourcehas already been initialized)- 另请参阅:
PropertySource.StubPropertySource,WebApplicationContextUtils.initServletPropertySources(MutablePropertySources, ServletContext),ConfigurableEnvironment.getPropertySources()