diff options
Diffstat (limited to 'src/main/java/pl/edu/mimuw')
3 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java new file mode 100644 index 0000000..79df04e --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -0,0 +1,22 @@ +package pl.edu.mimuw.cloudatlas.agent; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + +public class Agent { + public static void main(String[] args) { + try { + ApiImplementation api = new ApiImplementation(); + Api apiStub = + (Api) UnicastRemoteObject.exportObject(api, 0); + Registry registry = LocateRegistry.getRegistry(); + registry.rebind("Api", apiStub); + System.out.println("Api bound"); + } catch (Exception e) { + System.err.println("Agent exception:"); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java new file mode 100644 index 0000000..c0003a8 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java @@ -0,0 +1,11 @@ +package pl.edu.mimuw.cloudatlas.agent; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +import pl.edu.mimuw.cloudatlas.model.ValueSet; + +public interface Api extends Remote { + public int ping(int n) throws RemoteException; + public ValueSet getZones() throws RemoteException; +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java new file mode 100644 index 0000000..fc7532d --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java @@ -0,0 +1,23 @@ +package pl.edu.mimuw.cloudatlas.agent; + +import java.rmi.RemoteException; + +import java.util.Set; +import java.util.HashSet; + +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueSet; +import pl.edu.mimuw.cloudatlas.model.ValueNull; +import pl.edu.mimuw.cloudatlas.model.TypePrimitive; + +public class ApiImplementation implements Api { + public int ping(int n) throws RemoteException { + return n + 1; + } + + public ValueSet getZones() throws RemoteException { + Set<Value> set = new HashSet(); + set.add(ValueNull.getInstance()); + return new ValueSet(set, TypePrimitive.STRING); + } +} |