Headline

Distribution based on RMI in Java

Characteristics

We can think of the server as a centralized information system that maintains a number of companies. We can also think of the server as the information system for a given company. In both cases, the client remote accesses the company objects. For instance, the calculation of the salary total is to be done by the server.

Architecture

Package org.softlang.shared.company defines interfaces for the company object model. The members of these interfaces have a throws declaration for remote exceptions. Also, the interfaces derive from the Remote interface. Package org.softlang.server.company implements the aforementioned interfaces as POJOs with methods for total and cut. There is also Factory class in that package for convenience. The class Server in the package org.softlang.server implements an (RMI) server. To this end, a sample company is bound in the registry. The server keeps on running until terminated explicitly. The class Client in the package org.softlang.client implements an (RMI) client. To this end, the sample company is looked up from the server. Methods for totaling and cutting salaries are executed on the resulting proxy object.

Usage

  • The implementation is provided as an Eclipse project.
  • Hence, open the project with Eclipse; this will also build the project.
  • The simple scenario of running server and client on the same machine is exercised as follows:
    • Start the server from the command line; see the Makefile.
    • Start the client from within Eclipse; class org.softlang.client.Client.
    • Both server and client produce some standard output.
    • The client terminates automatically, and can be restarted any number of times.
    • The server must be terminated explicitly at the command line.

General tips and tricks on RMI

a) Running the applications

Even if you are not using make, look at the Makefiles for illustration.

b) Running both server and client on the local machine.

The following advice may be helpful in running both the client and the server parts of an RMI application on a single machine. When you use RMI, and you want to connect in the client to the server, you need to know the IP address (hostname) of the server. For testing purposes, it is indeed common to run both client and server on the same machine. One typically refers to the given machine by localhost or 127.0.0.1, but depending on network setup, the actual IP address or the DNS-resolvable machine name may (need to) be used.

c) Ports and firewall exceptions

RMI requires some ports to be accessible.

Also RMI may require special firewall settings.

RMI uses port 1099 by default. See: "LocateRegistry.createRegistry(Registry.REGISTRY PORT);" All ports from 1024 may be used.

In Windows, the following firewall exceptions may be needed:

 C:\WINDOWS\system32\java.exe
 C:\Programme\Java\jdk1.6.0 06\bin\rmiregistry.exe
 C:\Programme\Java\jdk1.6.0 06\bin\java.exe

d) Security policy


The server of the application is started with a security manager. See org.softlang.server.Server.java. Hence we *must* grant some RMI-related rights; see file security.policy. Also, the policy file must be passed to the server. See Makefile. The policy is very permissive; see the wildcard.

The implementation has been tested with Java version 5.


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.