RMI大杂烩

作者: 编程小世界 | 来源:发表于2019-04-27 19:05 被阅读0次

packageio.github.baijifeilong.rmi;importjava.rmi.Remote;importjava.rmi.RemoteException;publicinterfaceISayHelloServiceextendsRemote{Stringhello(String name)throwsRemoteException;}

服务端

packageio.github.baijifeilong.rmi;importjava.rmi.RemoteException;importjava.rmi.registry.LocateRegistry;importjava.rmi.server.UnicastRemoteObject;publicclassRmiServer{publicstaticvoidmain(String[] args)throwsRemoteException{        ISayHelloService sayHelloService =newSayHelloService();        UnicastRemoteObject.exportObject(sayHelloService,0);        LocateRegistry.createRegistry(1099).rebind("SayHello", sayHelloService);    }staticclassSayHelloServiceimplementsISayHelloService{@OverridepublicStringhello(String name){return"hello, "+ name;        }    }}

客户端

package io.github.baijifeilong.rmi;importjava.rmi.NotBoundException;importjava.rmi.RemoteException;importjava.rmi.registry.LocateRegistry;importjava.rmi.registry.Registry;publicclassRmiClient{publicstaticvoid main(String[] args)throwsRemoteException,NotBoundException{// RMI默认端口1099,不需要显式声明Registryregistry =LocateRegistry.getRegistry();ISayHelloServicesayHelloService = (ISayHelloService) registry.lookup("SayHello");System.out.println(sayHelloService.hello("word"));    }}

进群:697699179可以获取Java各类入门学习资料!

这是我的微信公众号【编程study】各位大佬有空可以关注下,每天更新Java学习方法,感谢!

学习中遇到问题有不明白的地方,推荐加小编Java学习群:697699179内有视频教程 ,直播课程 ,等学习资料,期待你的加入

相关文章

  • RMI大杂烩

    packageio.github.baijifeilong.rmi;importjava.rmi.Remote;i...

  • RMI注意事项

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

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

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

  • Java RMI服务搭建

    什么是RMI? RMI:远程方法调用(Remote Method Invocation)。 如何建立RMI服务? ...

  • 分布式通信框架 - rmi

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

  • RMI、LDAP、CORBA与JNDI攻击

    1. RMI 1.1 JAVA RMI 1.1.1 基本概念 RMI(Remote Method Invocati...

  • 关于RPC

    1.RMI RMI(Remote Method Invocation,远程方法调用),RMI使用Java语言接口定...

  • spring05-RMI---G05

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

  • 分布式架构基础:Java RMI详解

    RMI简介 ​ Java RMI,即 远程方法调用(Remote Method Invocation),...

  • java之RMI

    什么是RMI The Java Remote Method Invocation (RMI) system all...

网友评论

    本文标题:RMI大杂烩

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