org.springframework.context.support.ClassPathXmlApplicationContext#destroy ( )源码实例Demo

下面列出了org.springframework.context.support.ClassPathXmlApplicationContext#destroy ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: octo-rpc   文件: ThriftConsumerMultiApi.java
public static void main(String[] args) {
    try {
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("thrift/multiport/thrift-consumer-multiapi.xml");

        HelloService.Iface userService = (HelloService.Iface) beanFactory.getBean("helloService");
        System.out.println(userService.sayHello("Emma"));

        Echo.Iface echo = (Echo.Iface) beanFactory.getBean("echoService");
        System.out.println(echo.echo("Hello world"));

        beanFactory.destroy();
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码2 项目: dubbo-2.6.5   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL) serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码3 项目: octo-rpc   文件: ThriftConsumer.java
public static void main(String[] args) {
    try {
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("thrift/zkmock/thrift-consumer.xml");

        HelloService.Iface userservice = (HelloService.Iface) beanFactory.getBean("helloService");
        System.out.println(userservice.sayHello("Emma"));

        beanFactory.destroy();
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码4 项目: octo-rpc   文件: MultiRoleService.java
public static void main(String[] args) {
    try {
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("thrift/multirole/thrift-multiroles.xml");

        HelloService.Iface userservice = (HelloService.Iface) beanFactory.getBean("helloService");
        System.out.println(userservice.sayHello("Emma"));

        beanFactory.destroy();
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码5 项目: octo-rpc   文件: ThriftConsumer.java
public static void main(String[] args) {
    try {
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("thrift/simple/thrift-consumer.xml");

        HelloService.Iface userService = (HelloService.Iface) beanFactory.getBean("helloService");
        System.out.println(userService.sayHello("OCTO"));

        beanFactory.destroy();
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码6 项目: octo-rpc   文件: ThriftConsumer.java
public static void main(String[] args) {
    try {
        ClassPathXmlApplicationContext beanFactory = new ClassPathXmlApplicationContext("thrift/zkregistry/thrift-consumer.xml");

        HelloService.Iface userService = (HelloService.Iface) beanFactory.getBean("helloService");
        System.out.println(userService.sayHello("Emma"));

        beanFactory.destroy();
        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码7 项目: octo-rpc   文件: DoradoDemo.java
public static void main(String[] args) throws TException, InterruptedException, IOException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
    final Echo.Iface client = context.getBean("clientProxy", Echo.Iface.class);

    Thread[] threads = new Thread[num];

    for (int i = 0; i < num; i++) {
        final int finalI = i;
        threads[i] = new Thread(new Runnable() {
            @Override
            public void run() {
                String result = null;
                Random random = new Random();
                for (int j = 0; j < num; j++) {
                    try {
                        result = client.echo("hello" + finalI + "," + j);
                        Thread.sleep(random.nextInt(100));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    assert ("echo: hello" + finalI + "," + j).equals(result);
                }
            }
        });
        threads[i].start();
    }

    for (Thread t : threads) {
        t.join();
    }

    context.destroy();
    System.exit(0);
}
 
源代码8 项目: dubbox   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL)serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码9 项目: dubbox-hystrix   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL)serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码10 项目: dubbo3   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL)serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码11 项目: dubbox   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL)serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码12 项目: ignite   文件: SpringBeanExample.java
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 * @throws Exception If example execution failed.
 */
public static void main(String[] args) throws Exception {
    System.out.println();
    System.out.println(">>> Spring bean example started.");

    // Initialize Spring factory.
    ClassPathXmlApplicationContext ctx =
        new ClassPathXmlApplicationContext("org/apache/ignite/examples/misc/springbean/spring-bean.xml");

    try {
        // Get ignite from Spring (note that local cluster node is already started).
        Ignite ignite = (Ignite)ctx.getBean("mySpringBean");

        // Execute any method on the retrieved ignite instance.
        ExecutorService exec = ignite.executorService();

        Future<String> res = exec.submit(new Callable<String>() {
            @Override public String call() throws Exception {
                System.out.println("Hello world!");

                return null;
            }
        });

        // Wait for callable completion.
        res.get();

        System.out.println(">>>");
        System.out.println(">>> Finished executing Ignite \"Spring bean\" example.");
        System.out.println(">>> You should see printed out of 'Hello world' on one of the nodes.");
        System.out.println(">>> Check all nodes for output (this node is also part of the cluster).");
        System.out.println(">>>");
    }
    finally {
        // Stop local cluster node.
        ctx.destroy();
    }
}
 
源代码13 项目: activemq-artemis   文件: SpringExample.java
public static void main(String[] args) throws Exception {
   System.out.println("Creating bean factory...");
   ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"spring-jms-beans.xml"});
   MessageSender sender = (MessageSender) context.getBean("MessageSender");
   System.out.println("Sending message...");
   sender.send("Hello world");
   Thread.sleep(100);
   context.destroy();
}
 
源代码14 项目: dubbox   文件: ConfigTest.java
@Test
public void testGenericServiceConfigThroughSpring() throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/generic-export.xml");
    try {
        ctx.start();
        ServiceConfig serviceConfig = (ServiceConfig) ctx.getBean("dubboDemoService");
        URL url = (URL)serviceConfig.getExportedUrls().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        ctx.destroy();
    }
}
 
源代码15 项目: java-course-ee   文件: InitDestroyExample.java
public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"springContext.xml"});

    log.debug("\n\n\n");

    Thread.sleep(5000);

    log.debug("Destroying context...");
    context.destroy();
}