Java Reference
In-Depth Information
// the following methods should be overriden in every
// subclass
public void init() {}
// executed when the activity is started
public void step() {}
// executed while the thread is alive
public void quit() {}
// executed before the activity is stopped
Class DProcess is the superclass of every control module. It implements
methods to register the control module in the RMI registry and methods to
start and stop control services. Every concrete control module will have its
own specific resources and will implement methods to allow its activities to
access them concurrently.
public class DProcess extends UnicastRemoteObject {
private String name; // name of this process
private String address; // IP address of the host
private int ID # 0; // used for activity identifiers
// list of running activities
private ArrayList activityList # new ArrayList();
public DProcess(String address, String name)
throws java.rmi.RemoteException {
this .address # address;
this .name # name;
try { // Registers the process with RMI
Naming.rebind(name, ((DProcess) this ) );
} catch (Exception e) { e.printStackTrace(); }
// This method can be invoked only by subclasses of
// DProcess, which implement specific methods for the
// creation and execution of their activities. It returns
// the activity's URL in the case of succesful activation,
// null otherwise
protected String startActivity(DActivity activity) {
try {
activity.setURL( this .name ! "_A" ! ( !! ID), address);
// Registers the activity
Naming.rebind(, activity );
return activity.getURL();
} catch (Exception e) { e.printStackTrace(); }
return null ;
Search WWH ::

Custom Search