RMIspring
1.业务接口类及其实现

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站制作、成都外贸网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的陇西网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
/**
* 定义一个远程接口
*/
public interface HelloService
{
/**
* 需要远程调用的方法
* @param msg
* @return
*/
String sayHello(String msg);
}public class HelloServiceImpl implements HelloService
{
public String sayHello(String msg)
{
return "server received the msg : " + msg;
}
}2.RmiServiceExporter(服务端)
3.RmiProxyFactoryBean(客户端)
4.测试
public class HelloServer
{
public static void main(String[] args)
{
new ClassPathXmlApplicationContext("spring-rmi-server.xml");
System.err.println("rmi 服务启动!");
}
}public class HelloClient
{
public static void main(String[] args)
{
ApplicationContext applicationContext
= new ClassPathXmlApplicationContext("spring-rmi-client.xml");
HelloService helloService
= (HelloService)applicationContext.getBean("helloService");
System.err.println(helloService.sayHello("测试测试!"));
}
}注:Registry服务的注册问题,有时会出现服务启动报错.
网站题目:RMIspring
标题网址:http://www.jxjierui.cn/article/pcgsej.html


咨询
建站咨询
