简体   繁体   中英

Java RMI server: Running servers with different data

I have a question about running multiple servers in JAVA RMI programming.

I should have 3 servers with the same functionality and different data in their hashmaps.

So my question is, could I create one class for servers and run multiple times, or create 3 different classes for servers.

Could I create one class for servers and run multiple times

Yes. Just supply the different HashMap data in the constructor.

You'll have to register all three instances in the Registry, under different names, or make them accessible via some other RMI mechanism.

Contrary to @JunedAhsan's answer, they can all share the same TCP port, and by default they will, if they're all exported from the same JVM, and there's no reason not to do that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM