本文整理匯總了Java中org.springframework.web.context.ConfigurableWebApplicationContext.getParent方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurableWebApplicationContext.getParent方法的具體用法?Java ConfigurableWebApplicationContext.getParent怎麽用?Java ConfigurableWebApplicationContext.getParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.context.ConfigurableWebApplicationContext
的用法示例。
在下文中一共展示了ConfigurableWebApplicationContext.getParent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createWebApplicationContext
import org.springframework.web.context.ConfigurableWebApplicationContext; //導入方法依賴的package包/類
protected WebApplicationContext createWebApplicationContext(ApplicationContext parent) {
Class<?> contextClass = getContextClass();
if (this.logger.isDebugEnabled()) {
this.logger.debug("Servlet with name '" + getServletName() +
"' will try to create custom WebApplicationContext context of class '" +
contextClass.getName() + "'" + ", using parent context [" + parent + "]");
}
if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) {
throw new ApplicationContextException(
"Fatal initialization error in servlet with name '" + getServletName() +
"': custom WebApplicationContext class [" + contextClass.getName() +
"] is not of type ConfigurableWebApplicationContext");
}
ConfigurableWebApplicationContext wac =
(ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
wac.setParent(parent);
if (wac.getParent() == null) {
ApplicationContext rootContext = (ApplicationContext) getServletContext().getAttribute("JetStreamRoot");
wac.setParent(rootContext);
}
wac.setConfigLocation(getContextConfigLocation());
configureAndRefreshWebApplicationContext(wac);
return wac;
}
示例2: customizeContext
import org.springframework.web.context.ConfigurableWebApplicationContext; //導入方法依賴的package包/類
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
super.customizeContext(servletContext, applicationContext);
if ( applicationContext.getParent() != null ) {
/* Only set resource locations if a parent exists */
String[] newLocations = clouCattleContext.getConfigLocationsForWeb(configuredParentName,
applicationContext.getConfigLocations());
applicationContext.setConfigLocations(newLocations);
}
}
示例3: customizeContext
import org.springframework.web.context.ConfigurableWebApplicationContext; //導入方法依賴的package包/類
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
super.customizeContext(servletContext, applicationContext);
if ( applicationContext.getParent() != null ) {
/* Only set resource locations if a parent exists */
String[] newLocations = cloudStackContext.getConfigLocationsForWeb(configuredParentName,
applicationContext.getConfigLocations());
applicationContext.setConfigLocations(newLocations);
}
}
示例4: initWebApplicationContext
import org.springframework.web.context.ConfigurableWebApplicationContext; //導入方法依賴的package包/類
/**
* Initialize and publish the WebApplicationContext for this servlet.
* <p>Delegates to {@link #createWebApplicationContext} for actual creation
* of the context. Can be overridden in subclasses.
* @return the WebApplicationContext instance
* @see #FrameworkServlet(WebApplicationContext)
* @see #setContextClass
* @see #setContextConfigLocation
*/
protected WebApplicationContext initWebApplicationContext() {
WebApplicationContext rootContext =
WebApplicationContextUtils.getWebApplicationContext(getServletContext());
WebApplicationContext wac = null;
if (this.webApplicationContext != null) {
// A context instance was injected at construction time -> use it
wac = this.webApplicationContext;
if (wac instanceof ConfigurableWebApplicationContext) {
ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) wac;
if (!cwac.isActive()) {
// The context has not yet been refreshed -> provide services such as
// setting the parent context, setting the application context id, etc
if (cwac.getParent() == null) {
// The context instance was injected without an explicit parent -> set
// the root application context (if any; may be null) as the parent
cwac.setParent(rootContext);
}
configureAndRefreshWebApplicationContext(cwac);
}
}
}
if (wac == null) {
// No context instance was injected at construction time -> see if one
// has been registered in the servlet context. If one exists, it is assumed
// that the parent context (if any) has already been set and that the
// user has performed any initialization such as setting the context id
wac = findWebApplicationContext();
}
if (wac == null) {
// No context instance is defined for this servlet -> create a local one
wac = createWebApplicationContext(rootContext);
}
if (!this.refreshEventReceived) {
// Either the context is not a ConfigurableApplicationContext with refresh
// support or the context injected at construction time had already been
// refreshed -> trigger initial onRefresh manually here.
onRefresh(wac);
}
if (this.publishContext) {
// Publish the context as a servlet context attribute.
String attrName = getServletContextAttributeName();
getServletContext().setAttribute(attrName, wac);
if (this.logger.isDebugEnabled()) {
this.logger.debug("Published WebApplicationContext of servlet '" + getServletName() +
"' as ServletContext attribute with name [" + attrName + "]");
}
}
return wac;
}