Spring中的RMI

作者: 大华夏 | 来源:发表于2017-07-01 23:39 被阅读157次

服务端

通过org.springframework.remoting.rmi.RmiServiceExporter来暴露接口,供远程来调用

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter">
        <!--提供的服务名称-->
        <property name="serviceName" value="HelloService" />
        <!--服务实现类引用-->
        <property name="service" ref="helloServiceImpl" />
        <!--暴露的服务接口-->
        <property name="serviceInterface"
            value="com.study.remoting.IHelloService" />
        <property name="registryPort" value="8080" />
        <property name="servicePort" value="8088" />
    </bean>
    <!--服务实现类对象-->
    <bean id="helloServiceImpl" class="com.study.remoting.HelloServiceImpl" />

</beans>

客户端

通过org.springframework.remoting.rmi.RmiProxyFactoryBean可以使用服务端暴露的服务

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="helloService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <!--引用RMI服务的地址-->
        <property name="serviceUrl" value="rmi://192.168.1.103:8080/HelloService" />
        <!--服务端暴露的接口类-->
        <property name="serviceInterface"
            value="com.study.remoting.IHelloService" />
    </bean>

</beans>

使用spring对RMI的支持,可以非常容易地构建你的分布式应用!!

相关文章

  • Spring中的RMI

    服务端 通过org.springframework.remoting.rmi.RmiServiceExporter...

  • Spring RMI配置

    在spring中通过org.springframework.remoting.rmi.RmiProxyFactor...

  • spring05-RMI---G05

    spring05-RMI 一. 远程方法调用 RMI Java RMI 指的是远程方法调用 (Remote Met...

  • 在Spring中配置RMI

    使用RMI服务 创建RMI服务的基本步骤 编写一个服务实现类,类中的方法必须抛出java.rmi.RemoteEx...

  • Spring整合RMI

    经常使用Java的一定知道RMI,当需要远程调用服务的是否,Java内嵌的RMI是非常有用的。但是创建调用RMI的...

  • RMI注意事项

    RMI服务接口 提供服务的RMI服务接口必须实现Remote接口 RMI服务启动 RMI服务端口 RMI需要两个端...

  • 什么是RMI 协议,Java中如何实现

    原文:什么是RMI 协议,Java中如何实现 - RelaxHeart网Tec博客 听故事,引入RMI 在了解什么...

  • 6.16 日报

    【说明:】今天主要做了任务八 一:今日完成 ⒈ task1—1 : spring rmi 远程访问 ⑴ 技能点 1...

  • 【程序员笔记】RMI使用笔记

    本文章共分为三部分 RMI简介 RMI原理 RMI使用 RMI实战 下面详细介绍 一 RMI简介 远程方法调用(R...

  • 分布式通信框架 - rmi

    1)什么是rmi 2)简单的实现rmi 3)rmi原理 4)手写rmi框架 进群:697699179可以获取Jav...

网友评论

    本文标题:Spring中的RMI

    本文链接:https://www.haomeiwen.com/subject/evogcxtx.html