Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

RMI spring

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

1. Service interface class and its implementation

/ * define a remote interface * / public interface HelloService {/ * methods that need to be called remotely * @ 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 (server side)

3.RmiProxyFactoryBean (client)

4. test

Public class HelloServer {public static void main (String [] args) {new ClassPathXmlApplicationContext ("spring-rmi-server.xml"); System.err.println ("rmi service startup!");}} 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 ("Test!");}}

Note: Registry service registration problems, sometimes there will be service startup error.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report