Java Code Examples for org.springframework.web.context.support.AnnotationConfigWebApplicationContext#setConfigLocation()

The following examples show how to use org.springframework.web.context.support.AnnotationConfigWebApplicationContext#setConfigLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvironmentSystemIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void annotationConfigWebApplicationContext() {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.setEnvironment(prodWebEnv);
	ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
	ctx.refresh();

	assertHasEnvironment(ctx, prodWebEnv);
	assertEnvironmentBeanRegistered(ctx);
	assertEnvironmentAwareInvoked(ctx, prodWebEnv);
}
 
Example 2
Source File: EnvironmentSystemIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void annotationConfigWebApplicationContext() {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.setEnvironment(prodWebEnv);
	ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
	ctx.refresh();

	assertHasEnvironment(ctx, prodWebEnv);
	assertEnvironmentBeanRegistered(ctx);
	assertEnvironmentAwareInvoked(ctx, prodWebEnv);
}
 
Example 3
Source File: EnvironmentSystemIntegrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void annotationConfigWebApplicationContext() {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.setEnvironment(prodWebEnv);
	ctx.setConfigLocation(EnvironmentAwareBean.class.getName());
	ctx.refresh();

	assertHasEnvironment(ctx, prodWebEnv);
	assertEnvironmentBeanRegistered(ctx);
	assertEnvironmentAwareInvoked(ctx, prodWebEnv);
}
 
Example 4
Source File: EchoWebApplicationInitializer.java    From restfbmessenger with Apache License 2.0 5 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation(this.getClass().getPackage().getName());
    servletContext.addListener(new ContextLoaderListener(context));
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/*");
}
 
Example 5
Source File: WebAppInitializer.java    From nio-multipart with Apache License 2.0 5 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("org.synchronoss.cloud.nio.multipart.example.config");
    context.setServletContext(servletContext);
    Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
    dynamic.setAsyncSupported(true);
    dynamic.addMapping("/");
    dynamic.setLoadOnStartup(1);

}
 
Example 6
Source File: WebInitializer.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
public void onStartup(ServletContext servletContext) {
	AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
	ctx.setConfigLocation("org.audt4j.demo.hibernate.config");
	servletContext.addListener(new ContextLoaderListener(ctx));
	ctx.setServletContext(servletContext);
	Dynamic servlet = servletContext.addServlet("dispatcher",
			new DispatcherServlet(ctx));
	servlet.addMapping("/*");
	servlet.setLoadOnStartup(1);
	FilterRegistration.Dynamic springSecurityFilterChain = servletContext
			.addFilter("springSecurityFilterChain",
					new DelegatingFilterProxy());
	springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");
	springSecurityFilterChain.setAsyncSupported(true);
}
 
Example 7
Source File: CustomWebAppInitializer.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void onStartup(ServletContext container) throws ServletException {

    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("com.baeldung.web.log");
    container.addListener(new ContextLoaderListener(context));

    ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/"); 

    container.addFilter("customRequestLoggingFilter", CustomeRequestLoggingFilter.class).addMappingForServletNames(null, false, "dispatcher");
}
 
Example 8
Source File: ApplicationInitializer.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onStartup(ServletContext servletContext) throws ServletException {

	/* Setting the configuration classes */
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation("qa.qcri.aidr.data.config");

	/*Configuring error handler filter for errors out isde the controllers
	FilterRegistration.Dynamic errorHandlerFilter = servletContext.addFilter("errorHandlerFilter", new ErrorHandlerFilter());
	errorHandlerFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
	*/
	FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter", new org.springframework.web.filter.CharacterEncodingFilter());
	encodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
	encodingFilter.setInitParameter("encoding", "UTF-8");
	encodingFilter.setInitParameter("forceEncoding", "true");
	
	/* Adding context listener */
	servletContext.addListener(new ContextLoaderListener(context));
	
	/* Adding request listener */
	servletContext.addListener(new RequestContextListener());

	/* Configuring dispatcher servlet for spring mvc */
	/*CustomDispatcherServlet servlet = new CustomDispatcherServlet(context); */
	ServletRegistration.Dynamic appServlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
	appServlet.setLoadOnStartup(1);
	appServlet.addMapping("/*");
}
 
Example 9
Source File: SpringMvcJettyComponentTestServer.java    From backstopper with Apache License 2.0 4 votes vote down vote up
private static WebApplicationContext generateWebAppContext(Class<?> springConfigClass) {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation(springConfigClass.getPackage().getName());
    return context;
}
 
Example 10
Source File: Main.java    From backstopper with Apache License 2.0 4 votes vote down vote up
private static WebApplicationContext generateWebAppContext() {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setConfigLocation("com.nike.backstopper.springsample.config");
    return context;
}
 
Example 11
Source File: WebApplicationConfiguration.java    From junit-servers with MIT License 4 votes vote down vote up
private AnnotationConfigWebApplicationContext getContext() {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation(configLocation());
	return context;
}
 
Example 12
Source File: WebApplicationConfiguration.java    From junit-servers with MIT License 4 votes vote down vote up
private AnnotationConfigWebApplicationContext getContext() {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation(configLocation());
	return context;
}
 
Example 13
Source File: WebApplicationConfiguration.java    From junit-servers with MIT License 4 votes vote down vote up
private AnnotationConfigWebApplicationContext getContext() {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation(configLocation());
	return context;
}
 
Example 14
Source File: WebApplicationConfiguration.java    From junit-servers with MIT License 4 votes vote down vote up
private AnnotationConfigWebApplicationContext getContext() {
	AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
	context.setConfigLocation(configLocation());
	return context;
}