Package org.springframework.web.context.support

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


     * @return
     */
    private ApplicationContext createSpringContext(ApplicationContext ctx,
                                                   ServletConfig sc,
                                                   String location) {
        XmlWebApplicationContext ctx2 = new XmlWebApplicationContext();
        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});           
        }
        ctx2.refresh();
        return ctx2;
    }
View Full Code Here


        List<String> servletLocations = new ArrayList<String>();
        servletLocations.add(CONTEXT_SERVLET);
        servletLocations.add(CONTEXT_TEST_SERVLET);
        servletLocations.addAll(localLocations);

        XmlWebApplicationContext servletContext = new XmlWebApplicationContext();
        servletContext.setParent(modelContext);
        servletContext.setConfigLocations(Iterables.toArray(servletLocations, String.class));
        servletContext.setAllowCircularReferences(true);
        servletContext.setAllowBeanDefinitionOverriding(true);

        MockServletContext mockServletContext = new MockServletContext();
        servletContext.setServletContext(mockServletContext);

        MockServletConfig mockServletConfig = new MockServletConfig(mockServletContext, "springServlet");
        servletContext.setServletConfig(mockServletConfig);

        servletContext.refresh();

        return servletContext;
    }
View Full Code Here

  public static WicketTester getWicketTester(long langId) {
    Application app = new Application();
       
    WicketTester tester = new WicketTester(app);
    ServletContext sc = app.getServletContext();
        XmlWebApplicationContext xmlContext = new XmlWebApplicationContext();
        xmlContext.setConfigLocation("classpath:openmeetings-applicationContext.xml");
        xmlContext.setServletContext(sc);
        xmlContext.refresh();
        sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext);
        if (langId > 0) {
          WebSession.get().setLanguage(langId);
        }
        InitializationContainer.initComplete = true;
View Full Code Here

    }

    public void testWithSpringContext() throws Exception {
       

        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, msc);

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

               
                break;               
            }
        }

        XmlWebApplicationContext wctx = new XmlWebApplicationContext();
        wctx.setParent(ctx);
        wctx.setConfigLocation("");
        wctx.setServletContext(servletContext);
        wctx.refresh();
       
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx);

        server.start();
       
View Full Code Here

                servletContext = context.getServletContext();
            }
        }

        XmlWebApplicationContext wctx = new XmlWebApplicationContext();
        wctx.setParent(ctx);
        wctx.setConfigLocation("");
        wctx.setServletContext(servletContext);
        wctx.refresh();
       
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx);

        server.start();
       
View Full Code Here

                servletContext = context.getServletContext();
            }
        }

        XmlWebApplicationContext wctx = new XmlWebApplicationContext();
        wctx.setParent(ctx);
        wctx.setConfigLocation("");
        wctx.setServletContext(servletContext);
        wctx.refresh();
       
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wctx);

        server.start();
       
View Full Code Here

  /**
   * Configures Spring.
   */
  private void configureSpring(ServletContextEvent arg0) {
    ConfigurableWebApplicationContext ctx = new XmlWebApplicationContext();
    ctx.setServletContext(arg0.getServletContext());

    URL defaultConfig = YFacesStartupListener.class.getResource(DEFAULT_YFACES_CTX);
    String[] configs = new String[] { defaultConfig.toExternalForm() };

    try {
      String yfacesCtx = arg0.getServletContext().getInitParameter(PARAM_YFACES_CTX);
      if (yfacesCtx != null) {
        URL customConfig = arg0.getServletContext().getResource(yfacesCtx);
        configs = new String[] { configs[0], customConfig.toExternalForm() };
      }
      log.debug("Using spring configuration:" + Arrays.asList(configs));
      ctx.setConfigLocations(configs);
      ctx.refresh();
      new YApplicationContext(ctx);

    } catch (MalformedURLException e) {
      e.printStackTrace();
    }
View Full Code Here

        this.applicationPassword = applicationPassword.trim();
    }

    public SecurityComponents createSecurityComponents() {
        // load the base configuration from the crowd-integration-client jar
        XmlWebApplicationContext crowdConfigContext = new XmlWebApplicationContext();
        crowdConfigContext.setClassLoader(getClass().getClassLoader());
        /*
         * crowdConfigContext .setConfigLocations(new String[] {
         * "classpath:/applicationContext-HudsonCrowdClient.xml" });
         */
        crowdConfigContext
                .setConfigLocations(new String[] { "classpath:/applicationContext-CrowdClient.xml" });
        crowdConfigContext.refresh();

        // load the Hudson-Crowd configuration from Crowd.groovy
        BeanBuilder builder = new BeanBuilder(crowdConfigContext, getClass().getClassLoader());
        Binding binding = new Binding();
        builder.parse(getClass().getResourceAsStream("Crowd.groovy"), binding);
        WebApplicationContext context = builder.createApplicationContext();

        // configure the ClientProperties object
        if (applicationName != null || applicationPassword != null || url != null) {
            Properties props = new Properties();
            props.setProperty("application.name", applicationName);
            props.setProperty("application.password", applicationPassword);
            props.setProperty("crowd.server.url", url);
            props.setProperty("session.validationinterval", "5");
            ClientProperties clientProperties = (ClientProperties) crowdConfigContext
                    .getBean("clientProperties");
            clientProperties.updateProperties(props);
        } else {
            log.warn("Client properties are incomplete");
        }
View Full Code Here

     * @return
     */
    private ApplicationContext createSpringContext(ApplicationContext ctx,
                                                   ServletConfig servletConfig,
                                                   String location) {
        XmlWebApplicationContext ctx2 = new XmlWebApplicationContext();
        createdContext = ctx2;
        ctx2.setServletConfig(servletConfig);
        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

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.