當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。