Global Positioning System Reference
In-Depth Information
implicitly creates and exports the object to the RMI runtime and turns it
into a server object to be referenced via network connections.
The main method creates a Registry to represent the actual network
address, where remote objects can be \published" or exported for interac-
tion. For the demo application (and simplification) on a single computer, a
SecurityManager is not used. Therefore, policy files are not required at this
point to avoid supplying the absolute path to the code base via command
line.
After construction of RealObjectsApplication , the server is online. Be-
fore clients can look up a reference to a remote-server object, it has to be
bound to a registry to be looked up with the registered string (with host
and port). Note that the (un)bind button only toggles the reachability for
clients. The clients who are already connected stay connected.
RMI hides the network protocols from the programmer and abstracts
them to the well known signature (API) of any other Java object. The
process of defining the object communication is the same as before: define
the semantics via interfaces and implement them:
RealObjectsApplication ...
implements RemoteServer, RemoteObjectsApplication
This class demonstrates the implementation of two interfaces for different
semantics. The RemoteServer represents the technical part of the commu-
nication to obtain a connection from client to server and enable the client
to retrieve general information like the server's time and space implemen-
tation.
With the remote interfaces, the initial Java vision as a remote-control
language (page 4) is complete. A Java object can obtain a reference to a
server, e.g., a television set, and invoke commands on the RemoteServer (or
stub in Java terminology).
Besides passing stubs, RMI also allows the transmission of Java objects.
Since these objects are transmitted by value, the programmer no longer has
to worry about unwanted references; the object is copied from one JVM
to another. The programmer can approve any object as an \exchange
particle" by tagging it as Serializable .
With the RemoteServer signature,
GPSinfo getGPSinfo() throws RemoteException
the connected client can receive a copy of a GPSinfo -type object without
knowing the actual implementation (in its import statements) and can ap-
ply its distance metrics.
The prexes Real... and Remote... of the classes reveal their role in
the ROAF:
RealObjectsApplication implements RemoteObjectsApplication
 
Search WWH ::




Custom Search