当前位置: 首页>>代码示例>>Java>>正文


Java ClassPathXmlApplicationContext.start方法代码示例

本文整理汇总了Java中org.springframework.context.support.ClassPathXmlApplicationContext.start方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPathXmlApplicationContext.start方法的具体用法?Java ClassPathXmlApplicationContext.start怎么用?Java ClassPathXmlApplicationContext.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.context.support.ClassPathXmlApplicationContext的用法示例。


在下文中一共展示了ClassPathXmlApplicationContext.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProviderNestedService

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testProviderNestedService() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/provider-nested-service.xml");
    ctx.start();
    try {
        ServiceConfig<DemoService> serviceConfig = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig");
        assertNotNull(serviceConfig.getProvider());
        assertEquals(2000, serviceConfig.getProvider().getTimeout().intValue());
        
        ServiceConfig<DemoService> serviceConfig2 = (ServiceConfig<DemoService>) ctx.getBean("serviceConfig2");
        assertNotNull(serviceConfig2.getProvider());
        assertEquals(1000, serviceConfig2.getProvider().getTimeout().intValue());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:19,代码来源:ConfigTest.java

示例2: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String config = VersionConsumer.class.getPackage().getName().replace('.', '/') + "/version-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();
    VersionService versionService = (VersionService) context.getBean("versionService");
    for (int i = 0; i < 10000; i ++) {
        String hello = versionService.sayHello("world");
        System.out.println(hello);
        Thread.sleep(2000);
    }
    System.in.read();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:VersionConsumer.java

示例3: testSystemPropertyOverrideXmlDefault

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testSystemPropertyOverrideXmlDefault() throws Exception {
    System.setProperty("dubbo.application.name", "sysover");
    System.setProperty("dubbo.application.owner", "sysowner");
    System.setProperty("dubbo.registry.address", "N/A");
    System.setProperty("dubbo.protocol.name", "dubbo");
    System.setProperty("dubbo.protocol.port", "20819");
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/system-properties-override-default.xml");
    providerContext.start();
    try {
        ServiceConfig<DemoService> service = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
        assertEquals("sysover", service.getApplication().getName());
        assertEquals("sysowner", service.getApplication().getOwner());
        assertEquals("N/A", service.getRegistry().getAddress());
        assertEquals("dubbo", service.getProtocol().getName());
        assertEquals(20819, service.getProtocol().getPort().intValue());
    } finally {
        System.setProperty("dubbo.application.name", "");
        System.setProperty("dubbo.application.owner", "");
        System.setProperty("dubbo.registry.address", "");
        System.setProperty("dubbo.protocol.name", "");
        System.setProperty("dubbo.protocol.port", "");
        providerContext.stop();
        providerContext.close();
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:28,代码来源:ConfigTest.java

示例4: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    String config = MergeConsumer.class.getPackage().getName().replace('.', '/') + "/merge-consumer.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();
    MergeService mergeService = (MergeService)context.getBean("mergeService");
    for (int i = 0; i < Integer.MAX_VALUE; i ++) {
        try {
            List<String> result = mergeService.mergeResult();
            System.out.println("(" + i + ") " + result);
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:16,代码来源:MergeConsumer.java

示例5: testMultiProtocol

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
public void testMultiProtocol() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol.xml");
    ctx.start();
    try {
        DemoService demoService = refer("dubbo://127.0.0.1:20881");
        String hello = demoService.sayName("hello");
        assertEquals("say:hello", hello);
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:14,代码来源:ConfigTest.java

示例6: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext context =
            new ClassPathXmlApplicationContext("dubbo-demo-consumer.xml");
    context.start();
    Demo.Iface demo = (Demo.Iface) context.getBean("demoService");
    System.out.println(demo.echoI32(32));
    for (int i = 0; i < 10; i++) {
        System.out.println(demo.echoI32(i + 1));
    }
    context.close();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:DubboDemoConsumer.java

示例7: testMultiProtocolError

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
public void testMultiProtocolError() {
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-error.xml");
        ctx.start();
        ctx.stop();
        ctx.close();
    } catch (BeanCreationException e) {
        assertTrue(e.getMessage().contains("Found multi-protocols"));
    }
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:12,代码来源:ConfigTest.java

示例8: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("ProviderSample.xml");
    ctx.start();
    synchronized (RpcBenchmarkServer.class) {
        try {
            RpcBenchmarkServer.class.wait();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:RpcBenchmarkServer.java

示例9: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String... args) throws IOException {
    ClassPathXmlApplicationContext context =
            new ClassPathXmlApplicationContext(
                    new String[] {"applicationContext.xml"});
    context.start();

    System.in.read(); // 按任意键退出
}
 
开发者ID:daishicheng,项目名称:outcomes,代码行数:9,代码来源:Main.java

示例10: main

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void main(String arg[]){
    //加载spring配置
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"classpath:spring-scheduler-context.xml"});
    context.start();

    System.out.println("=================================");
    System.out.println("[SCHEDULER服务]启动完成!!!");
    System.out.println("=================================");
}
 
开发者ID:liuxx001,项目名称:bird-java,代码行数:10,代码来源:Bootstrap.java

示例11: upload

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
public static void upload(){
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring-storage-fdfs.xml");
    applicationContext.start();
    FDFSAttachmentService fdfsAttachmentService = applicationContext.getBean(FDFSAttachmentService.class);

    //String url=fdfsAttachmentService.upload(new File("C:\\unintall.log"));
    //String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\header.jpg"));
    //String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\ERWin 7.3.zip"));
    //String url=fdfsAttachmentService.uploadWithUrl(new File("C:\\8月4日应用答疑(上)_知识讲解.avi"));
    String url = fdfsAttachmentService.uploadWithUrl(new File("D:\\logs\\error.log"));
    System.out.println(url);
    applicationContext.stop();
}
 
开发者ID:babymm,项目名称:mumu,代码行数:14,代码来源:FDFSAttachmentServiceImplTest.java

示例12: test_noMethodInterface_methodsKeyHasValue

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
public void test_noMethodInterface_methodsKeyHasValue() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-no-methods-interface.xml");
    ctx.start();
    try {
        ServiceBean bean = (ServiceBean) ctx.getBean("service");
        List<URL> urls = bean.getExportedUrls();
        assertEquals(1, urls.size());
        URL url = urls.get(0);
        assertEquals("sayName,getBox", url.getParameter("methods"));
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:16,代码来源:ConfigTest.java

示例13: test_RpcContext_getUrls

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
public void test_RpcContext_getUrls() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(
            ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-long-waiting.xml");
    providerContext.start();

    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                ConfigTest.class.getPackage().getName().replace('.', '/')
                        + "/init-reference-getUrls.xml");
        ctx.start();
        try {
            DemoService demoService = (DemoService) ctx.getBean("demoService");
            try {
                demoService.sayName("Haha");
                fail();
            } catch (RpcException expected) {
                assertThat(expected.getMessage(), containsString("Tried 3 times"));
            }

            assertEquals(3, RpcContext.getContext().getUrls().size());
        } finally {
            ctx.stop();
            ctx.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:31,代码来源:ConfigTest.java

示例14: testCustomizeParameter

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testCustomizeParameter() throws Exception {
    ClassPathXmlApplicationContext context =
            new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/customize-parameter.xml");
    context.start();
    ServiceBean<DemoService> serviceBean = (ServiceBean<DemoService>) context.getBean("demoServiceExport");
    URL url = (URL) serviceBean.toUrls().get(0);
    assertEquals("protocol-paramA", url.getParameter("protocol.paramA"));
    assertEquals("service-paramA", url.getParameter("service.paramA"));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:12,代码来源:ConfigTest.java

示例15: test_retrySettingFail

import org.springframework.context.support.ClassPathXmlApplicationContext; //导入方法依赖的package包/类
@Test
public void test_retrySettingFail() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(
            ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-long-waiting.xml");
    providerContext.start();

    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                ConfigTest.class.getPackage().getName().replace('.', '/')
                        + "/init-reference-retry-false.xml");
        ctx.start();
        try {
            DemoService demoService = (DemoService) ctx.getBean("demoService");
            try {
                demoService.sayName("Haha");
                fail();
            } catch (RpcException expected) {
                assertThat(expected.getMessage(), containsString("Tried 1 times"));
            }

            assertEquals(1, RpcContext.getContext().getUrls().size());
        } finally {
            ctx.stop();
            ctx.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:31,代码来源:ConfigTest.java


注:本文中的org.springframework.context.support.ClassPathXmlApplicationContext.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。