projet-donnees-reparties/linda/server/LindaServer.java

74 lines
2.1 KiB
Java
Raw Normal View History

2021-11-30 16:39:17 +00:00
package linda.server;
import java.util.Collection;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.*;
import java.rmi.registry.*;
import java.io.*;
2021-11-30 16:39:17 +00:00
import linda.Callback;
import linda.Linda;
import linda.Tuple;
import linda.shm.CentralizedLinda;
/**
* lindaServer
*/
public class LindaServer extends UnicastRemoteObject implements LindaRemote {
2021-11-30 16:39:17 +00:00
Linda lindaInstance;
public static void main(String[] args) {
try {
LindaServer ls = new LindaServer();
Registry registry = LocateRegistry.createRegistry(Integer.parseInt(args[1]));
Naming.rebind(args[0], ls);
2021-11-30 16:39:17 +00:00
System.out.println("L'instance Linda a été publié sur le registre (" + args[0] + ") !\n");
} catch (Exception e) {
e.printStackTrace();
}
}
public LindaServer() throws RemoteException {
this.lindaInstance = new CentralizedLinda();
}
public void write(Tuple t) {
lindaInstance.write(t);
System.out.println("Le tuple " + t + " a été ajouté au TupleSpace !");
}
public Tuple take(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.take(template);
}
public Tuple read(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.read(template);
}
public Tuple tryTake(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.tryTake(template);
}
public Tuple tryRead(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.tryRead(template);
}
public Collection<Tuple> takeAll(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.takeAll(template);
}
public Collection<Tuple> readAll(Tuple template) throws RemoteException {
2021-11-30 16:39:17 +00:00
return lindaInstance.readAll(template);
}
public void eventRegister(Linda.eventMode mode, Linda.eventTiming timing, Tuple template, Callback callback) throws RemoteException {
2021-11-30 16:39:17 +00:00
lindaInstance.eventRegister(mode, timing, template, callback);
}
public void debug(String prefix) throws RemoteException {
2021-11-30 16:39:17 +00:00
lindaInstance.debug(prefix);
}
}