當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassPathXmlApplicationContext.stop方法代碼示例

本文整理匯總了Java中org.springframework.context.support.ClassPathXmlApplicationContext.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassPathXmlApplicationContext.stop方法的具體用法?Java ClassPathXmlApplicationContext.stop怎麽用?Java ClassPathXmlApplicationContext.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.context.support.ClassPathXmlApplicationContext的用法示例。


在下文中一共展示了ClassPathXmlApplicationContext.stop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAnnotation

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testAnnotation() {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(AnnotationTest.class.getPackage().getName().replace('.', '/') + "/annotation-provider.xml");
    providerContext.start();
    try {
        ClassPathXmlApplicationContext consumerContext = new ClassPathXmlApplicationContext(AnnotationTest.class.getPackage().getName().replace('.', '/') + "/annotation-consumer.xml");
        consumerContext.start();
        try {
            AnnotationAction annotationAction = (AnnotationAction) consumerContext.getBean("annotationAction");
            String hello = annotationAction.doSayHello("world");
            assertEquals("annotation: hello, world", hello);
        } finally {
            consumerContext.stop();
            consumerContext.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:21,代碼來源:AnnotationTest.java

示例2: testMultiRegistry

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testMultiRegistry() {
    SimpleRegistryService registryService1 = new SimpleRegistryService();
    Exporter<RegistryService> exporter1 = SimpleRegistryExporter.export(4545, registryService1);
    SimpleRegistryService registryService2 = new SimpleRegistryService();
    Exporter<RegistryService> exporter2 = SimpleRegistryExporter.export(4546, registryService2);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-registry.xml");
    ctx.start();
    try {
        List<URL> urls1 = registryService1.getRegistered().get("com.alibaba.dubbo.config.spring.api.DemoService");
        assertNull(urls1);
        List<URL> urls2 = registryService2.getRegistered().get("com.alibaba.dubbo.config.spring.api.DemoService");
        assertNotNull(urls2);
        assertEquals(1, urls2.size());
        assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20880/com.alibaba.dubbo.config.spring.api.DemoService", urls2.get(0).toIdentityString());
    } finally {
        ctx.stop();
        ctx.close();
        exporter1.unexport();
        exporter2.unexport();
    }
}
 
開發者ID:zhuxiaolei,項目名稱:dubbo2,代碼行數:23,代碼來源:ConfigTest.java

示例3: testXmlOverrideProperties

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testXmlOverrideProperties() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/xml-override-properties.xml");
    providerContext.start();
    try {
        ApplicationConfig application = (ApplicationConfig) providerContext.getBean("application");
        assertEquals("demo-provider", application.getName());
        assertEquals("world", application.getOwner());
        
        RegistryConfig registry = (RegistryConfig) providerContext.getBean("registry");
        assertEquals("N/A", registry.getAddress());
        
        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20813, dubbo.getPort().intValue());
        
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:21,代碼來源:ConfigTest.java

示例4: testAnnotation

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testAnnotation() {
    SimpleRegistryService registryService = new SimpleRegistryService();
    Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4548, registryService);
    try {
        ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/annotation-provider.xml");
        providerContext.start();
        try {
            ClassPathXmlApplicationContext consumerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/annotation-consumer.xml");
            consumerContext.start();
            try {
                AnnotationAction annotationAction = (AnnotationAction) consumerContext.getBean("annotationAction");
                String hello = annotationAction.doSayName("hello");
                assertEquals("annotation:hello", hello);
            } finally {
                consumerContext.stop();
                consumerContext.close();
            }
        } finally {
            providerContext.stop();
            providerContext.close();
        }
    } finally {
        exporter.unexport();
    }
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:27,代碼來源:ConfigTest.java

示例5: testInitReference

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testInitReference() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider.xml");
    providerContext.start();
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/init-reference.xml");
        ctx.start();
        try {
            DemoService demoService = (DemoService)ctx.getBean("demoService");
            assertEquals("say:world", demoService.sayName("world"));
        } finally {
            ctx.stop();
            ctx.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:20,代碼來源:ConfigTest.java

示例6: testMultiProtocolRegister

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testMultiProtocolRegister() {
    SimpleRegistryService registryService = new SimpleRegistryService();
    Exporter<RegistryService> exporter = SimpleRegistryExporter.export(4547, registryService);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-register.xml");
    ctx.start();
    try {
        List<URL> urls = registryService.getRegistered().get("com.alibaba.dubbo.config.spring.api.DemoService");
        assertNotNull(urls);
        assertEquals(1, urls.size());
        assertEquals("dubbo://" + NetUtils.getLocalHost() + ":20824/com.alibaba.dubbo.config.spring.api.DemoService", urls.get(0).toIdentityString());
    } finally {
        ctx.stop();
        ctx.close();
        exporter.unexport();
    }
}
 
開發者ID:zhuxiaolei,項目名稱:dubbo2,代碼行數:18,代碼來源:ConfigTest.java

示例7: test_returnSerializationFail

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void test_returnSerializationFail() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/demo-provider-UnserializableBox.xml");
    providerContext.start();
    try {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/init-reference.xml");
        ctx.start();
        try {
            DemoService demoService = (DemoService)ctx.getBean("demoService");
            try {
                demoService.getBox();
                fail();
            } catch (RpcException expected) {
                assertThat(expected.getMessage(), containsString("must implement java.io.Serializable"));
            }
        } finally {
            ctx.stop();
            ctx.close();
        }
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:flychao88,項目名稱:dubbocloud,代碼行數:25,代碼來源:ConfigTest.java

示例8: testSystemPropertyOverrideMultiProtocol

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testSystemPropertyOverrideMultiProtocol() throws Exception {
    System.setProperty("dubbo.protocol.dubbo.port", "20814");
    System.setProperty("dubbo.protocol.rmi.port", "10914");
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/override-multi-protocol.xml");
    providerContext.start();
    try {
        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20814, dubbo.getPort().intValue());
        ProtocolConfig rmi = (ProtocolConfig) providerContext.getBean("rmi");
        assertEquals(10914, rmi.getPort().intValue());
    } finally {
        System.setProperty("dubbo.protocol.dubbo.port", "");
        System.setProperty("dubbo.protocol.rmi.port", "");
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:19,代碼來源:ConfigTest.java

示例9: 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

示例10: testServiceClass

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testServiceClass() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/service-class.xml");
    ctx.start();
    try {
        DemoService demoService = refer("dubbo://127.0.0.1:20887");
        String hello = demoService.sayName("hello");
        assertEquals("welcome:hello", hello);
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:14,代碼來源:ConfigTest.java

示例11: testMultiProtocolDefault

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testMultiProtocolDefault() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-default.xml");
    ctx.start();
    try {
        DemoService demoService = refer("rmi://127.0.0.1:10991");
        String hello = demoService.sayName("hello");
        assertEquals("say:hello", hello);
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:14,代碼來源:ConfigTest.java

示例12: 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:dachengxi,項目名稱:EatDubbo,代碼行數:12,代碼來源:ConfigTest.java

示例13: testSystemPropertyOverrideXml

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testSystemPropertyOverrideXml() 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");
    System.setProperty("dubbo.service.register", "false");
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/system-properties-override.xml");
    providerContext.start();
    try {
        ServiceConfig<DemoService> service = (ServiceConfig<DemoService>) providerContext.getBean("demoServiceConfig");
        URL url = service.toUrls().get(0);
        assertEquals("sysover", url.getParameter("application"));
        assertEquals("sysowner", url.getParameter("owner"));
        assertEquals("dubbo", url.getProtocol());
        assertEquals(20819, url.getPort());
        String register = url.getParameter("register");
        assertTrue(register != null && !"".equals(register));
        assertEquals(false, Boolean.valueOf(register));
    } 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", "");
        System.setProperty("dubbo.service.register", "");
        providerContext.stop();
        providerContext.close();
    }
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:33,代碼來源:ConfigTest.java

示例14: 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:zhuxiaolei,項目名稱:dubbo2,代碼行數:31,代碼來源:ConfigTest.java

示例15: testSpringExtensionInject

import org.springframework.context.support.ClassPathXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void testSpringExtensionInject() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/spring-extension-inject.xml");
    ctx.start();
    try {
        MockFilter filter = (MockFilter) ExtensionLoader.getExtensionLoader(Filter.class).getExtension("mymock");
        assertNotNull(filter.getMockDao());
        assertNotNull(filter.getProtocol());
        assertNotNull(filter.getLoadBalance());
    } finally {
        ctx.stop();
        ctx.close();
    }
}
 
開發者ID:yunhaibin,項目名稱:dubbox-hystrix,代碼行數:15,代碼來源:ConfigTest.java


注:本文中的org.springframework.context.support.ClassPathXmlApplicationContext.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。