Example usage for org.springframework.web.context.support XmlWebApplicationContext setConfigLocation

List of usage examples for org.springframework.web.context.support XmlWebApplicationContext setConfigLocation

Introduction

In this page you can find the example usage for org.springframework.web.context.support XmlWebApplicationContext setConfigLocation.

Prototype

public void setConfigLocation(String location) 

Source Link

Document

Set the config locations for this application context in init-param style, i.e.

Usage

From source file:org.springsource.sinspctr.AdminMain.java

/**
* Launch stream server with the given home and transport
 * @throws IOException /*from  ww w.  j ava 2s  . com*/
*/
static InspctrServer launchStreamServer() throws IOException {
    XmlWebApplicationContext context = new XmlWebApplicationContext();
    context.setConfigLocation("classpath:" + CONFIG_ROOT + "sinspctr-server.xml");

    // Not making StreamServer a spring bean eases move to .war file if
    // needed
    final InspctrServer server = new InspctrServer(context, DEFAULT_PORT);
    server.afterPropertiesSet();
    server.start();
    StringBuilder runtimeInfo = new StringBuilder(
            String.format("Running in Local Mode on port: %s ", server.getPort()));
    System.out.println(BannerUtils.displayBanner(null, runtimeInfo.toString()));
    context.addApplicationListener(new ApplicationListener<ContextClosedEvent>() {
        @Override
        public void onApplicationEvent(ContextClosedEvent event) {
            server.stop();
        }
    });
    context.registerShutdownHook();
    return server;
}

From source file:com.cisco.oss.foundation.tools.simulator.rest.startup.SingleRestSimulatorStartup.java

public static void startServer() {
    try {//w  ww .ja v a 2 s. c om

        ListMultimap<String, Servlet> servlets = ArrayListMultimap.create();
        ListMultimap<String, Filter> filters = ArrayListMultimap.create();

        // Set the init params
        Map<String, String> initParams = new HashMap<String, String>();
        initParams.put("com.sun.jersey.config.property.packages", "com.cisco.oss.foundation.tools");

        // Create the servlet
        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());

        JettyHttpServerFactory.INSTANCE.startHttpServer(SINGLE_REST_SIMULATOR, servlets, filters,
                eventListeners, initParams);

        //         ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
        //               "META-INF/applicationContext.xml");
        //         server = (Server) applicationContext.getBean("restSimJettyServer");
        //
        //         server.start();
    } catch (Exception ex) {
        logger.error("Error Starting REST Simulator" + ex);
    }
}

From source file:com.predic8.membrane.servlet.RouterUtil.java

public static Router initializeRoutersFromSpringWebContext(XmlWebApplicationContext appCtx,
        final ServletContext ctx, String configLocation) {
    appCtx.setServletContext(ctx);/*ww  w . ja v a  2 s .c  o  m*/
    appCtx.setConfigLocation(configLocation);
    appCtx.refresh();

    Collection<Router> routers = appCtx.getBeansOfType(Router.class).values();
    Router theOne = null;
    for (Router r : routers) {
        r.getResolverMap().addSchemaResolver(new FileSchemaWebAppResolver(ctx));
        if (r.getTransport() instanceof ServletTransport) {
            if (theOne != null)
                throw new RuntimeException("Only one <router> may have a <servletTransport> defined.");
            theOne = r;
        }
    }

    appCtx.start();

    return theOne;
}

From source file:de.itsvs.cwtrpc.controller.config.AutowiredRemoteServiceGroupConfigBeanDefinitionParserTest.java

@BeforeClass
public static void initClass() {
    ServletContext servletContext;// w  ww  . ja  v a2s. co  m
    XmlWebApplicationContext appContext;

    servletContext = new MockServletContext();
    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "AutowiredRemoteServiceGroupConfigBeanDefinitionParserTest1.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();

    AutowiredRemoteServiceGroupConfigBeanDefinitionParserTest.appContext = appContext;
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParserTest.java

@BeforeClass
public static void initClass() {
    ServletContext servletContext;/*from  ww w  .  j a  v a  2s .c om*/
    XmlWebApplicationContext appContext;

    servletContext = new MockServletContext();

    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "RemoteServiceControllerConfigBeanDefinitionParserTest1.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();
    RemoteServiceControllerConfigBeanDefinitionParserTest.appContext = appContext;
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceModuleConfigBeanDefinitionParserTest.java

@BeforeClass
public static void initClass() {
    ServletContext servletContext;/*w  w w  . j a  v  a2 s.c o m*/
    XmlWebApplicationContext appContext;

    servletContext = new MockServletContext();

    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "RemoteServiceModuleConfigBeanDefinitionParserTest1.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();
    RemoteServiceModuleConfigBeanDefinitionParserTest.appContext = appContext;
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceGroupConfigBeanDefinitionParserTest.java

@BeforeClass
public static void initClass() {
    ServletContext servletContext;// w ww .  j a  va2 s. c o  m
    XmlWebApplicationContext appContext;

    servletContext = new MockServletContext();

    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "RemoteServiceGroupConfigBeanDefinitionParserTest1.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();
    RemoteServiceGroupConfigBeanDefinitionParserTest.appContext = appContext;

    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "RemoteServiceGroupConfigBeanDefinitionParserTest2.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();
    RemoteServiceGroupConfigBeanDefinitionParserTest.appContext2 = appContext;
}

From source file:de.itsvs.cwtrpc.controller.config.CacheControlConfigBeanDefinitionParserTest.java

@BeforeClass
public static void initClass() {
    ServletContext servletContext;/*  w  w w . ja  v  a2  s  .  com*/
    XmlWebApplicationContext appContext;

    servletContext = new MockServletContext();
    appContext = new XmlWebApplicationContext();
    appContext.setConfigLocation("classpath:/de/itsvs/cwtrpc/controller/config/"
            + "CacheControlConfigBeanDefinitionParserTest1.xml");
    appContext.setServletContext(servletContext);
    appContext.refresh();

    CacheControlConfigBeanDefinitionParserTest.appContext = appContext;
}

From source file:com.dm.platform.spring.MyWebAppInitializer.java

protected WebApplicationContext createServletApplicationContext() {
    XmlWebApplicationContext cxt = new XmlWebApplicationContext();
    cxt.setConfigLocation("/WEB-INF/dispatcher-servlet.xml");
    return cxt;/*  w  w  w .  j  a va  2s  .c om*/
}

From source file:gov.nih.nci.clinicalconnector.service.globus.ClinicalConnectorProviderImpl.java

public ClinicalConnectorProviderImpl() throws RemoteException {
    XmlWebApplicationContext c = new XmlWebApplicationContext();
    c.setConfigLocation("classpath:applicationContext.xml");
    c.refresh();/*from   w  w  w  .j av a2 s.co m*/
    impl = (ClinicalConnectorImpl) c.getBean("clinicalConnectorService");
}