Re: Java<->invoke RMI method by hand

Niclas Hedhman <[email protected]> Mon, 16 Mar 2009 08:54:10 +0800
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
On Sun, Mar 15, 2009 at 8:52 PM, Alex Co <[email protected]> wrote:
> Hi all,
>
> I have a home made JVM without support for RMI (but it has socket support)
> and the Sun JVM with RMI support.
>
> Suppose I have a RMI remote object running on the 192.168.0.1 computer by
> using the SUN JVM.
>
> Suppose I have my custom JVM on a x86 (286) computer and I want to invoke a
> method on the other JVM.
>
> Is it possible to invoke the server side method by implementing by hand the
> call that a normal stub class does?

Yes I think so. But note that there is an ObjectId, that is created on
the server.

Here is what I think you could do;

1. Obtain the RemoteStub on the server, through exportObject().

2. Serialize the RemoteStub. (IIRC, serializing the exported object
will also create a serialized RemoteStub.)

3. Through some other mechanism, pass that serialized stub to your
foreign VM, for instance via a socket.

4. Deserialize it there, and execute.

For that to work, you will need both Serialization support and have
implemented the MarshalledObject.

Now, you say that you don't have RMI support, but looking at how you
formulate the question, I suspect that you don't have Serialization
support either. If so, you are in much deeper water, in which case I
recommend you to look into alternative serialization and RPC systems,
such as Apache Thrift or Apache Etch (incubator), or even JAX-WS/WS-*
(although very slow). You can probably do a bit of home-grown system
as well with a generic serializer such as XStream and "being clever"
(it is pretty straight-forward process, and the tricky bits are in the
error handling).


Cheers
Niclas
-- 
http://www.qi4j.org - New Energy for Java

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html