Package org.springframework.web.context.support

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


            serverConfiguration = "classpath:server_application.xml";
        }
        try {
            final ServletContext servletContext = event.getServletContext();

            context = new XmlWebApplicationContext();
            context.setServletContext(servletContext);
            context.setConfigLocations(StringUtils.tokenizeToStringArray(serverConfiguration, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS));
            context.refresh();

            servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
View Full Code Here


      logger.info("Using a web application context: {}", context);
      return context;
    }
    if (DefaultSpringLocator.class.getResource("/applicationContext.xml") != null) {
      logger.info("Using an XmlWebApplicationContext, searching for applicationContext.xml");
      XmlWebApplicationContext ctx = new XmlWebApplicationContext();
      ctx.setConfigLocation("classpath:applicationContext.xml");
      servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
      return ctx;
    }
    logger.info("No application context found");
    ConfigurableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setId("VRaptor");
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
    return ctx;
  }
View Full Code Here

      logger.info("Using a web application context: " + context);
      return context;
    }
    if (DefaultSpringLocator.class.getResource("/applicationContext.xml") != null) {
      logger.info("Using an XmlWebApplicationContext, searching for applicationContext.xml");
      XmlWebApplicationContext ctx = new XmlWebApplicationContext();
      ctx.setConfigLocation("classpath:applicationContext.xml");
      return ctx;
    }
    logger.info("No application context found");
    ConfigurableWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.setId("VRaptor");
    return ctx;
  }
View Full Code Here

    private WebApplicationContext createWebapplicationContext(ServletContext servletContext) {
        String webconsoleType = System.getProperty("webconsole.type", "embedded");
        String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";

        XmlWebApplicationContext context = new XmlWebApplicationContext();
        context.setServletContext(servletContext);
        context.setConfigLocations(new String[] {
            configuration
        });
        context.refresh();
        context.start();

        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);

        return context;
    }
View Full Code Here

        ConnectionFactory connectionFactory = (ConnectionFactory)context.getBean("connectionFactory");
        servletContext.setAttribute(WebClient.CONNECTION_FACTORY_ATTRIBUTE, connectionFactory);
    }

    public void contextDestroyed(ServletContextEvent event) {
        XmlWebApplicationContext context = (XmlWebApplicationContext)WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
        if (context != null) {
            context.stop();
            context.destroy();
        }
        // do nothing, since the context is destoyed anyway
    }
View Full Code Here

     * @return
     */
    private ApplicationContext createSpringContext(ApplicationContext ctx,
                                                   ServletConfig sc,
                                                   String location) {
        XmlWebApplicationContext ctx2 = new XmlWebApplicationContext();
        createdContext = ctx2;
        ctx2.setServletConfig(sc);

        Resource r = ctx2.getResource(location);
        try {
            InputStream in = r.getInputStream();
            in.close();
        } catch (IOException e) {
            //ignore
            r = ctx2.getResource("classpath:" + location);
            try {
                r.getInputStream().close();
            } catch (IOException e2) {
                //ignore
                r = null;
            }
        }
        try {
            if (r != null) {
                location = r.getURL().toExternalForm();
            }
        } catch (IOException e) {
            //ignore
        }       
        if (ctx != null) {
            ctx2.setParent(ctx);
            String names[] = ctx.getBeanNamesForType(Bus.class);
            if (names == null || names.length == 0) {
                ctx2.setConfigLocations(new String[] {"classpath:/META-INF/cxf/cxf.xml",
                                                      location});               
            } else {
                ctx2.setConfigLocations(new String[] {location});                               
            }
        } else {
            ctx2.setConfigLocations(new String[] {"classpath:/META-INF/cxf/cxf.xml",
                                                  location});
            createdContext = ctx2;
        }
        ctx2.refresh();
        return ctx2;
    }
View Full Code Here

   *
   * @return application context instance
   */
  protected ConfigurableWebApplicationContext newApplicationContext()
  {
    return new XmlWebApplicationContext();
  }
View Full Code Here

            ResourceConfig resourceConfig = new ResourceConfig();
            resourceConfig.packages("com.cisco.oss.foundation.tools");
            ServletContainer resourceServlet = new ServletContainer(resourceConfig);
            servlets.put("/*", resourceServlet);

      XmlWebApplicationContext webConfig = new XmlWebApplicationContext();
      webConfig.setConfigLocation("classpath:META-INF/restSimulatorContext.xml");
      webConfig.registerShutdownHook();

            List<EventListener> eventListeners = new ArrayList<EventListener>();
            eventListeners.add(new ContextLoaderListener(webConfig));
            eventListeners.add(new RequestContextListener());

View Full Code Here

    }
  }

  public static Map<String, BeanDefinition> getApplicationBeanDefinitions() {
    Map<String, BeanDefinition> map = new HashMap<String, BeanDefinition>();
    XmlWebApplicationContext context = (XmlWebApplicationContext) SpringApplicationContextHolder
        .getWebApplicationContext();
    ConfigurableListableBeanFactory factory = context.getBeanFactory();
    String[] names = factory.getBeanDefinitionNames();
    for (String name : names) {
      map.put(name, factory.getBeanDefinition(name));
    }
    return map;
View Full Code Here

    return map;
  }

  public static Map<String, BeanDefinition> getDispatcherBeanDefinitions() {
    Map<String, BeanDefinition> map = new HashMap<String, BeanDefinition>();
    XmlWebApplicationContext context = (XmlWebApplicationContext) SpringDispatcherContextHolder
        .getWebApplicationContext();
    ConfigurableListableBeanFactory factory = context.getBeanFactory();
    String[] names = factory.getBeanDefinitionNames();
    for (String name : names) {
      map.put(name, factory.getBeanDefinition(name));
    }
    return map;
View Full Code Here

TOP

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

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.