Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do we really need to create Stub in java RMI?

Tags:

java

rmi

I am reading some RMI document and all the books say that we need to create Stub for the client in order to communicate with the server. However, I have tried to not create stub and things worked like a charm. I have put the client program on one machine and the server on another, things worked perfectly. So, what is actually the purpose of creating Stub and do we really need to create one? Thanks.

like image 623
ipkiss Avatar asked Apr 04 '11 10:04

ipkiss


People also ask

Why are stub used in RMI?

RMI uses a standard mechanism (employed in RPC systems) for communicating with remote objects: stubs and skeletons. A stub for a remote object acts as a client's local representative or proxy for the remote object.

What is the role of stub and skeleton in RMI?

Stub − A stub is a representation (proxy) of the remote object at client. It resides in the client system; it acts as a gateway for the client program. Skeleton − This is the object which resides on the server side. stub communicates with this skeleton to pass request to the remote object.

What is the purpose of stub and skeleton classes?

The stub and skeleton classes are responsible for dispatching and processing RMI requests. Developers should not write these classes, however. Once a service implementation exists, the rmic tool, which ships with the JDK, should be used to create them.

What is the role of stub?

A stub may simulate the behavior of existing code (such as a procedure on a remote machine; such methods are often called mocks) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in porting, distributed computing as well as general software development and testing.


1 Answers

Since Java 1.5 you don't have to:

This release adds support for the dynamic generation of stub classes at runtime, obviating the need to use [...] stub compiler, rmic, to pregenerate stub classes for remote objects. Note that rmic must still be used to pregenerate stub classes for remote objects that need to support clients running on earlier versions.

From http://download.oracle.com/javase/1.5.0/docs/guide/rmi/relnotes.html

like image 180
Tomasz Nurkiewicz Avatar answered Sep 21 '22 00:09

Tomasz Nurkiewicz