Commit c5a310f3 authored by Mohamad Bashar Desoki's avatar Mohamad Bashar Desoki

EX3

parent c5192b5e
package org.ds.EX3.client;
public class Clint {
import org.ds.EX3.shared.IClientCallBack;
import org.ds.EX3.shared.IComputeAndNotify;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
public static void main(String[] args) throws RemoteException, NotBoundException {
Registry registry = LocateRegistry.getRegistry(1099);
IComputeAndNotify iComputeAndNotify = (IComputeAndNotify) registry.lookup("ComputeAndNotifySVC");
IClientCallBack iClientCallBack = new ClientCallBackImp();
iComputeAndNotify.computeAndNotify(10,5,iClientCallBack);
}
}
package org.ds.EX3.client;
public class ClientCallBackImp {
import org.ds.EX3.shared.IClientCallBack;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class ClientCallBackImp extends UnicastRemoteObject implements IClientCallBack {
protected ClientCallBackImp() throws RemoteException {
}
@Override
public void notify(String Message) throws RemoteException {
System.out.println("Received Callback:" +Message);
}
}
package org.ds.EX3.server;
public class ComputeAndNotifySVCImp {
import org.ds.EX3.shared.IClientCallBack;
import org.ds.EX3.shared.IComputeAndNotify;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class ComputeAndNotifySVCImp extends UnicastRemoteObject implements IComputeAndNotify {
protected ComputeAndNotifySVCImp() throws RemoteException {
}
@Override
public void computeAndNotify(int a, int b, IClientCallBack clientCallBack) throws RemoteException {
int res = a+b;
clientCallBack.notify("Result: " + res);
}
}
package org.ds.EX3.server;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Server {
public static void main(String[] args) throws RemoteException {
Registry registry = LocateRegistry.createRegistry(1099);
ComputeAndNotifySVCImp computeAndNotifySVCImp = new ComputeAndNotifySVCImp();
registry.rebind("ComputeAndNotifySVC", computeAndNotifySVCImp);
System.out.println("Ready");
}
}
package org.ds.EX3.shared;
public interface IClientCallBack {
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IClientCallBack extends Remote {
public void notify(String Message) throws RemoteException;
}
package org.ds.EX3.shared;
public interface IComputeAndNotify {
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IComputeAndNotify extends Remote {
public void computeAndNotify(int a,int b, IClientCallBack clientCallBack) throws RemoteException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment