Call Cancellation Example

Introduction

This page provides examples for how to use the net.jini.config.Configuration and net.jini.export.Exporter interfaces to create programs whose use of remote communication is configurable. The page includes references to the source files for the application as well as to the files needed to configure the application in different ways.

You can explore the contents of the files below to provide a starting point for designing and configuring applications. Follow the directions to run the example application in different configurations. The package documentation for com.sun.jini.example.cancellation may be found here.

Note that, for simplicity, the examples use file URLs for codebases. A deployed application should not use file URLs for codebases, but should instead rely on another URL protocol.

Files

These examples use a client application that spawns a thread to invoke the remote method Ping.ping on a server and then cancels the remote call in progress in that thread. The client passes the ping method a reference to a remote object implementing the ReceiveReady interface that is executing in the client. The server's ping method notifies the client that the method is executing by calling the client's ready method. When the client's ready method is invoked by the server, the client cancels the ping remote call.

The server's proxy implements the CallCancellation interface, so the client can cast the proxy to that interface and invoke its cancelCall(Thread) method to cancel the call in the thread. The following classes represent the client-side API for call cancellation:

The remaining source file CancelILFactory.java contains a factory used to customize invocation and dispatch behavior to handle call cancellation. The server object is exported to use this factory in conjunction with Jini(TM) extensible remote invocation (Jini ERI).

There are two manifest files used in the build process:

There are one server configuration and two client configurations. The files for configuring and running the server are:

The two client configurations are:

  1. Client using Jini ERI

  2. Client using JRMP

All clients use the same security policy file:

This example uses the rmiregistry. Files for running rmiregistry are also supplied:

There is a UNIX makefile for building the example as needed:

Directions for running the example

These examples depend on the Jini(TM) Technology Starter Kit (starter kit) platform files jsk-platform.jar and jsk-resources.jar, which can be found in the lib directory of the starter kit. Copy these two files into the lib directory under the cancellation directory. The lib directory under cancellation should now contain the following files:

    classes
    client-dl.jar
    client.jar
    jsk-platform.jar
    jsk-resources.jar
    server-dl.jar
    server.jar

Note: To run the examples, make sure to run each command with the cancellation directory as the current working directory.

Before running any example configurations, start a new Java(TM) Remote Method Invocation (Java RMI) registry with the cancellation directory as the current working directory. If a Java RMI registry is already running in a different directory, make sure to kill the existing registry first. On UNIX platforms:

   scripts/rmiregistry.sh &

On Microsoft Windows platforms:

   start scripts/rmiregistry

To run an example configuration, start the server and then the client. Make sure to wait for the server to print the message "ready" before running the client. For example, on UNIX platforms:

   sh scripts/server.sh &
   sh scripts/jeri-client.sh

On Microsoft Windows platforms:

   start scripts\server
   start scripts\jeri-client

Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.