Examples of XmlWebApplicationContext


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

    }
   
    public void testPostHandleWithStandardRedirectPrefix() throws Exception {
        AjaxInterceptor ajaxInterceptor = (AjaxInterceptor) this.applicationContext.getBean("ajaxInterceptor");
       
        XmlWebApplicationContext springContext = new XmlWebApplicationContext();
        MockServletContext servletContext = new MockServletContext();
        springContext.setConfigLocations(this.getConfigLocations());
        springContext.setServletContext(servletContext);
        springContext.refresh();
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
       
        MockHttpServletRequest httpRequest = new MockHttpServletRequest(servletContext, "POST", "/ajax/submit.action");
        MockHttpSession session = new MockHttpSession(servletContext);
        httpRequest.setSession(session);
View Full Code Here

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

    }
   
    public void testPostHandleFailsWithUnsupportedEventException() throws Exception {
        AjaxInterceptor ajaxInterceptor = (AjaxInterceptor) this.applicationContext.getBean("ajaxInterceptor");
       
        XmlWebApplicationContext springContext = new XmlWebApplicationContext();
        MockServletContext servletContext = new MockServletContext();
        springContext.setConfigLocations(this.getConfigLocations());
        springContext.setServletContext(servletContext);
        springContext.refresh();
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
       
        MockHttpServletRequest httpRequest = new MockHttpServletRequest(servletContext, "POST", "/ajax/submit.action");
        MockHttpSession session = new MockHttpSession(servletContext);
        httpRequest.setSession(session);
View Full Code Here

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

    }
   
    public void testPostHandleFailsWithNoMatchingHandlerException() throws Exception {
        AjaxInterceptor ajaxInterceptor = (AjaxInterceptor) this.applicationContext.getBean("ajaxInterceptor");
       
        XmlWebApplicationContext springContext = new XmlWebApplicationContext();
        MockServletContext servletContext = new MockServletContext();
        springContext.setConfigLocations(this.getConfigLocations());
        springContext.setServletContext(servletContext);
        springContext.refresh();
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
       
        MockHttpServletRequest httpRequest = new MockHttpServletRequest(servletContext, "POST", "/ajax/submit2.action");
        MockHttpSession session = new MockHttpSession(servletContext);
        httpRequest.setSession(session);
View Full Code Here

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

    }
   
    public void testPostHandleStopsBecauseOfNoModelAndView() throws Exception {
        AjaxInterceptor ajaxInterceptor = (AjaxInterceptor) this.applicationContext.getBean("ajaxInterceptor");
       
        XmlWebApplicationContext springContext = new XmlWebApplicationContext();
        MockServletContext servletContext = new MockServletContext();
        springContext.setConfigLocations(this.getConfigLocations());
        springContext.setServletContext(servletContext);
        springContext.refresh();
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);
       
        MockHttpServletRequest httpRequest = new MockHttpServletRequest(servletContext, "POST", "/ajax/simple.page");
        MockHttpSession session = new MockHttpSession(servletContext);
        httpRequest.setSession(session);
View Full Code Here

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

    public void testWithSpringContext() throws Exception {
        Container container = EasyMock.createNiceMock(Container.class);
        EasyMock.replay(container);

        ConfigurableWebApplicationContext ac = new XmlWebApplicationContext();
        ServletContext msc = (ServletContext) new MockServletContext();
        msc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
        ac.setServletContext(msc);
        ac.setConfigLocations(new String[] {"org/apache/struts2/spring/StrutsSpringObjectFactoryTest-applicationContext.xml"});
        ac.refresh();
        StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory("constructor", null, null, msc, null, container);

        assertEquals(AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, fac.getAutowireStrategy());
    }
View Full Code Here

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

        // 只有需要重新加载时才进行SPRING指定bean加载
        if (DynamicDeployUtil.isReload() && DynamicDeployUtil.isReloadResource(_SPRING_CONFIG_NAME)) {
            try {
//                ClassLoader loader = LoaderUtil.getCurrentLoaderParentLoader();
//                Thread.currentThread().setContextClassLoader(loader);
                XmlWebApplicationContext xmlWebApplicationContext = (XmlWebApplicationContext) ContextLoader.getCurrentWebApplicationContext();
                DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) xmlWebApplicationContext.getBeanFactory();
                Properties pros = new Properties();
                defaultListableBeanFactory.setBeanClassLoader(LoaderUtil.getClassLoader());
                pros.load(new ByteArrayInputStream(DynamicDeployUtil.findResource(_SPRING_CONFIG_NAME)));
                for (String key : pros.stringPropertyNames()) {
                    BeanDefinition beanDefinition = defaultListableBeanFactory.getBeanDefinition(key);
View Full Code Here

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

    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

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

        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

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

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

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

     * @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
TOP
Copyright © 2018 www.massapi.com. 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.