简体   繁体   中英

Communication between Java programs with non-JDK objects

I'm looking for a communication channel between two java programs running on the same machine. I've found a few options (RMI and XML-RCP) but none of the examples that I found show exchange of objects wich class it's non-primitive and not know on JDK (our own objects).

So, what's the easy technology to use when I want to do this (note that Utils.jar it's on the classpath of Server.jar and Client.jar):

Utils.jar:

class MyClassRequestParams { ... }

class MyClassReturnParams { ... }

Client.jar:

// Server creation
...

// Send request
MyClassRequestParams params = new MyClass...

MyClassReturnParams response = server.send("serverMethodName", params);

Server.jar:

MyClassRequestParams serverMethodName(MyClassRequestParams params)
{
   MyClassReturnParams response = new MyC...

   // do processing

   return response;

}

Just make your transport classes implement the Serializable interface, and everything will be fine with RMI. Note that every object referenced bt the transport object should also be Serializable.

The RMI tutorial uses an example with a custom Task interface implemented by a Pi custom class that is not a "standard" JDK class.

You may also consider Versile Java (I am one of its developers). Follow the link for an example of making remote calls and defining remote interfaces. It implements a platform-independent standard for remote ORB interaction, currently also available for python.

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