本文整理汇总了Java中org.springframework.web.context.support.AnnotationConfigWebApplicationContext.setParent方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationConfigWebApplicationContext.setParent方法的具体用法?Java AnnotationConfigWebApplicationContext.setParent怎么用?Java AnnotationConfigWebApplicationContext.setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.context.support.AnnotationConfigWebApplicationContext
的用法示例。
在下文中一共展示了AnnotationConfigWebApplicationContext.setParent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applicationContext
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
protected WebApplicationContext applicationContext() {
if (applicationContext == null) {
AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
Set<Class<?>> annotatedClasses = annotatedClasses();
if (annotatedClasses != null) {
annotatedClasses.iterator().forEachRemaining(webApplicationContext::register);
}
Set<? extends BeanFactoryPostProcessor> beanFactoryPostProcessors = beanFactoryPostProcessors();
if (beanFactoryPostProcessors != null) {
beanFactoryPostProcessors.iterator().forEachRemaining(webApplicationContext::addBeanFactoryPostProcessor);
}
if (this.rootApplicationContext != null) {
webApplicationContext.setParent(this.rootApplicationContext);
webApplicationContext.setEnvironment((ConfigurableEnvironment) rootApplicationContext.getEnvironment());
}
applicationContext = webApplicationContext;
}
return (WebApplicationContext) applicationContext;
}
示例2: initSpring
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Initializes Spring and Spring MVC.
*/
private void initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext appDispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
appDispatcherServletConfiguration.setParent(rootContext);
appDispatcherServletConfiguration.register(AppDispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic appDispatcherServlet = servletContext.addServlet("appDispatcher", new DispatcherServlet(appDispatcherServletConfiguration));
appDispatcherServlet.addMapping("/app/*");
appDispatcherServlet.setLoadOnStartup(1);
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext apiDispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
apiDispatcherServletConfiguration.setParent(rootContext);
apiDispatcherServletConfiguration.register(ApiDispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic apiDispatcherServlet = servletContext.addServlet("apiDispatcher", new DispatcherServlet(apiDispatcherServletConfiguration));
apiDispatcherServlet.addMapping("/api/*");
apiDispatcherServlet.setLoadOnStartup(1);
}
示例3: initSpring
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Initializes Spring and Spring MVC.
*/
private void initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext appDispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
appDispatcherServletConfiguration.setParent(rootContext);
appDispatcherServletConfiguration.register(AppDispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic appDispatcherServlet = servletContext.addServlet("appDispatcher",
new DispatcherServlet(appDispatcherServletConfiguration));
appDispatcherServlet.addMapping("/app/*");
appDispatcherServlet.setLoadOnStartup(1);
appDispatcherServlet.setAsyncSupported(true);
LOGGER.debug("Registering Flowable public REST API");
AnnotationConfigWebApplicationContext apiDispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
apiDispatcherServletConfiguration.setParent(rootContext);
apiDispatcherServletConfiguration.register(ApiDispatcherServletConfiguration.class);
ServletRegistration.Dynamic apiDispatcherServlet = servletContext.addServlet("apiDispatcher",
new DispatcherServlet(apiDispatcherServletConfiguration));
apiDispatcherServlet.addMapping("/api/*");
apiDispatcherServlet.setLoadOnStartup(1);
apiDispatcherServlet.setAsyncSupported(true);
}
示例4: initSpring
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Initializes Spring and Spring MVC.
*/
private void initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext appDispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
appDispatcherServletConfiguration.setParent(rootContext);
appDispatcherServletConfiguration.register(AppDispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic appDispatcherServlet = servletContext.addServlet("appDispatcher", new DispatcherServlet(appDispatcherServletConfiguration));
appDispatcherServlet.addMapping("/app/*");
appDispatcherServlet.setLoadOnStartup(1);
appDispatcherServlet.setAsyncSupported(true);
initSpringProcessRest(servletContext, rootContext);
initSpringDMNRest(servletContext, rootContext);
initSpringFormRest(servletContext, rootContext);
initSpringContentRest(servletContext, rootContext);
}
示例5: initSpringRestComponent
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
protected ServletRegistration.Dynamic initSpringRestComponent(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext,
String restContextRoot, Class<? extends WebMvcConfigurationSupport> webConfigClass) {
LOGGER.debug("Configuring Spring Web application context - {} REST", restContextRoot);
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(webConfigClass);
LOGGER.debug("Registering Spring MVC Servlet - {} REST", restContextRoot);
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet(restContextRoot + "-dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping("/" + restContextRoot + "/*");
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.setAsyncSupported(true);
return dispatcherServlet;
}
示例6: initSpringRestComponent
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
protected ServletRegistration.Dynamic initSpringRestComponent(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext,
String name, String restContextRoot, Class<? extends WebMvcConfigurationSupport> webConfigClass) {
LOGGER.debug("Configuring Spring Web application context - {} REST", name);
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(webConfigClass);
LOGGER.debug("Registering Spring MVC Servlet - {} REST", name);
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet(name + "-dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping(restContextRoot + "/*");
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.setAsyncSupported(true);
return dispatcherServlet;
}
示例7: initSpring
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Initializes Spring and Spring MVC.
*/
private ServletRegistration.Dynamic initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(DispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping("/service/*");
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.setAsyncSupported(true);
return dispatcherServlet;
}
示例8: initSpring
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Initializes Spring and Spring MVC.
*/
private void initSpring(ServletContext servletContext, AnnotationConfigWebApplicationContext rootContext) {
LOGGER.debug("Configuring Spring Web application context");
AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
dispatcherServletConfiguration.setParent(rootContext);
dispatcherServletConfiguration.register(DispatcherServletConfiguration.class);
LOGGER.debug("Registering Spring MVC Servlet");
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServletConfiguration));
dispatcherServlet.addMapping("/app/*");
dispatcherServlet.setLoadOnStartup(1);
}
示例9: loadContext
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; //导入方法依赖的package包/类
/**
* Load a Spring {@link WebApplicationContext} from the supplied
* {@link MergedContextConfiguration}.
* <p/>
* <p>Implementation details:
* <p/>
* <ul>
* <li>Calls {@link #validateMergedContextConfiguration(WebMergedContextConfiguration)}
* to allow subclasses to validate the supplied configuration before proceeding.</li>
* <li>Creates a {@link GenericWebApplicationContext} instance.</li>
* <li>If the supplied {@code MergedContextConfiguration} references a
* {@linkplain MergedContextConfiguration#getParent() parent configuration},
* the corresponding {@link MergedContextConfiguration#getParentApplicationContext()
* ApplicationContext} will be retrieved and
* {@linkplain GenericWebApplicationContext#setParent(ApplicationContext) set as the parent}
* for the context created by this method.</li>
* <li>Delegates to {@link #configureWebResources} to create the
* {@link MockServletContext} and set it in the {@code WebApplicationContext}.</li>
* <li>Calls {@link #prepareContext} to allow for customizing the context
* before bean definitions are loaded.</li>
* <li>Delegates to {@link #loadBeanDefinitions} to populate the context
* from the locations or classes in the supplied {@code MergedContextConfiguration}.</li>
* <li>Delegates to {@link AnnotationConfigUtils} for
* {@linkplain AnnotationConfigUtils#registerAnnotationConfigProcessors registering}
* annotation configuration processors.</li>
* <li>Calls {@link #customizeContext} to allow for customizing the context
* before it is refreshed.</li>
* <li>{@link ConfigurableApplicationContext#refresh Refreshes} the
* context and registers a JVM shutdown hook for it.</li>
* </ul>
*
* @return a new web application context
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
* @see GenericWebApplicationContext
*/
@Override
public final AnnotationConfigWebApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
SingularContextSetup.reset();
if (!(mergedConfig instanceof WebMergedContextConfiguration)) {
throw new IllegalArgumentException(String.format(
"Cannot load WebApplicationContext from non-web merged context configuration %s. "
+ "Consider annotating your test class with @WebAppConfiguration.", mergedConfig));
}
WebMergedContextConfiguration webMergedConfig = (WebMergedContextConfiguration) mergedConfig;
if (logger.isDebugEnabled()) {
logger.debug(String.format("Loading WebApplicationContext for merged context configuration %s.",
webMergedConfig));
}
validateMergedContextConfiguration(webMergedConfig);
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
ApplicationContext parent = mergedConfig.getParentApplicationContext();
if (parent != null) {
context.setParent(parent);
}
configureWebResources(context, webMergedConfig);
prepareContext(context, webMergedConfig);
customizeContext(context, webMergedConfig);
loadBeanDefinitions(context, webMergedConfig);
mockRequest();
context.refresh();
context.registerShutdownHook();
return context;
}