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.
Client.java - the client
application
Server.java - the server
application
ReceiveReady.java - the client
remote interface
Ping.java - the server remote interface
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:
CallCancellation.java
- interface for proxies supporting call cancellation
CallCancelledException.java
- exception thrown as a result of a cancelled remote method
NoSuchCallException.java
- exception thrown to indicate no cancellable remote call is executing
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:
config/server.config -
server configuration file
config/server.policy -
server security policy file
scripts/server.bat -
batch file to run server
scripts/server.sh -
shell script to run server
The two client configurations are:
config/jeri-client.config - client configuration file
scripts/jeri-client.bat - batch file to run client
scripts/jeri-client.sh - shell script to run client
config/jrmp-client.config - client configuration file
scripts/jrmp-client.bat - batch file to run client
scripts/jrmp-client.sh - shell script to run client
All clients use the same security policy file:
config/client.policy -
client security policy file
This example uses the rmiregistry. Files for
running rmiregistry are also supplied:
scripts/rmiregistry.bat
- batch file to start rmiregistry
scripts/rmiregistry.sh -
shell script to start rmiregistry
config/rmiregistry.policy
- policy file for rmiregistry
There is a UNIX makefile for building the example as needed:
build.xml -
ANT build scripts for building the example
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