Java Reference
In-Depth Information
import java.rmi.RemoteException;
import Negotiation.Preference;
public interface ServerInterface extends java.rmi.Remote {
public void registerProvider(String providerURL,
String providerName) throws RemoteException;
public void negotiate(String clientURL,
String providerName, Preference preference)
throws RemoteException;
}
The Server class implements the ServerInterface and extends the MMI class
DProcess . The constructor specifies the name by which the server will be
accessible.
package agent;
import mmi.DProcess;
import Negotiation.*;
import java.util.*;
import java.rmi.RemoteException;
import java.rmi.Naming;
public class Server extends DProcess implements
ServerInterface {
final static String NAME # "NegotiationServer";
private Map providers # new Hashtable();
public Server(String address) throws RemoteException {
super (address,NAME);
}
public void registerProvider(String providerURL,
String name)
throws RemoteException{
try {
Preference preference # (Preference)Naming.lookup
(providerURL);
providers.put(name,new NegotiationAgent
( this ,providerURL,preference));
} catch (Exception e){ e.printStackTrace(); }
}
public void negotiate(String clientURL, String providerName,
Preference preference) throws RemoteException{
// find the appropriate provider agent and start it
NegotiationAgent provider #
(NegotiationAgent) providers.get(providerName);
startActivity(provider);
// create the client negotiation agent and start it
Search WWH ::




Custom Search