Package org.springframework.web.context.support

Examples of org.springframework.web.context.support.AnnotationConfigWebApplicationContext


  /**
   * Factory method to create {@link AnnotationConfigWebApplicationContext} instances.
   */
  private AnnotationConfigWebApplicationContext createContext(final Class<?>... annotatedClasses) {
    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.register(annotatedClasses);
    return context;
  }
View Full Code Here


* @author Jon Brisbin
*/
public class RestExporterWebInitializer implements WebApplicationInitializer {

  @Override public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
    rootCtx.register(
        JpaRepositoryConfig.class,
        MongoDbRepositoryConfig.class
        //GemfireRepositoryConfig.class,
        //Neo4jRepositoryConfig.class
    );

    servletContext.addListener(new ContextLoaderListener(rootCtx));
    //    servletContext.addFilter("springSecurity", DelegatingFilterProxy.class);
    //    servletContext.getFilterRegistration("springSecurity").addMappingForUrlPatterns(
    //        EnumSet.of(DispatcherType.REQUEST),
    //        false,
    //        "/*"
    //    );

    AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext();
    webCtx.register(RestExporterExampleRestConfig.class);

    DispatcherServlet dispatcherServlet = new DispatcherServlet(webCtx);
    ServletRegistration.Dynamic reg = servletContext.addServlet("rest-exporter", dispatcherServlet);
    reg.setLoadOnStartup(1);
    reg.addMapping("/*");
 
View Full Code Here

    private static final String DISPATCHER_SERVLET_NAME = "dispatcher";
    private static final String DISPATCHER_SERVLET_MAPPING = "/";
   
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(ApplicationContext.class);

        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);
View Full Code Here

    this.serverContainer = mock(ServerContainer.class);

    this.servletContext = new MockServletContext();
    this.servletContext.setAttribute("javax.websocket.server.ServerContainer", this.serverContainer);

    this.webAppContext = new AnnotationConfigWebApplicationContext();
    this.webAppContext.register(Config.class);
    this.webAppContext.setServletContext(this.servletContext);
    this.webAppContext.refresh();

    this.exporter = new ServerEndpointExporter();
View Full Code Here

  @Before
  public void setup() {
    this.servletContext = new MockServletContext();

    this.webAppContext = new AnnotationConfigWebApplicationContext();
    this.webAppContext.register(Config.class);

    this.contextLoader = new ContextLoader(this.webAppContext);
    this.contextLoader.initWebApplicationContext(this.servletContext);
View Full Code Here

  public void teardown() {
    ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
  }

  private void setup(Class<?> configurationClass) {
    AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
    applicationContext.register(configurationClass);
    applicationContext.refresh();
    this.applicationContext = applicationContext;
    ContextLoaderTestUtils.setCurrentWebApplicationContext(this.applicationContext);
  }
View Full Code Here

    logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" +
        this.webSocketClient.getClass().getSimpleName() + ", server=" +
        this.server.getClass().getSimpleName());

    this.wac = new AnnotationConfigWebApplicationContext();
    this.wac.register(getAnnotatedConfigClasses());
    this.wac.register(upgradeStrategyConfigTypes.get(this.server.getClass()));
    this.wac.refresh();

    if (this.webSocketClient instanceof Lifecycle) {
View Full Code Here

  @Before
  public void setup() throws Exception {
    logger.debug("Setting up '" + this.testName.getMethodName() + "'");
    this.errorFilter = new ErrorFilter();
    this.wac = new AnnotationConfigWebApplicationContext();
    this.wac.register(TestConfig.class, upgradeStrategyConfigClass());
    this.wac.refresh();
    this.server = createWebSocketTestServer();
    this.server.setup();
    this.server.deployConfig(this.wac, this.errorFilter);
View Full Code Here

   */
  @Override
  protected WebApplicationContext createRootApplicationContext() {
    Class<?>[] configClasses = getRootConfigClasses();
    if (!ObjectUtils.isEmpty(configClasses)) {
      AnnotationConfigWebApplicationContext rootAppContext = new AnnotationConfigWebApplicationContext();
      rootAppContext.register(configClasses);
      return rootAppContext;
    }
    else {
      return null;
    }
View Full Code Here

   * <p>This implementation creates an {@link AnnotationConfigWebApplicationContext},
   * providing it the annotated classes returned by {@link #getServletConfigClasses()}.
   */
  @Override
  protected WebApplicationContext createServletApplicationContext() {
    AnnotationConfigWebApplicationContext servletAppContext = new AnnotationConfigWebApplicationContext();
    Class<?>[] configClasses = getServletConfigClasses();
    if (!ObjectUtils.isEmpty(configClasses)) {
      servletAppContext.register(configClasses);
    }
    return servletAppContext;
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.context.support.AnnotationConfigWebApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.