Search in sources :

Example 1 with Counter

use of examples.mvc.local.duplex.Counter in project GIPC by pdewan.

the class ADistributedRMIClientMVC_Launcher method getCounter.

@Override
protected Counter getCounter() {
    DistributedRMICounter counter = new ADistributedInheritingRMICounter();
    try {
        UnicastRemoteObject.exportObject(counter, 0);
        Registry clientRMIRegistry = LocateRegistry.getRegistry();
        clientRMIRegistry.rebind(counterName(), counter);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return (Counter) counter;
}
Also used : Counter(examples.mvc.local.duplex.Counter) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 2 with Counter

use of examples.mvc.local.duplex.Counter in project GIPC by pdewan.

the class ASessionPortCounterClientLauncher method createUI.

@Override
protected void createUI(InputPort anInputPort) {
    Scanner aScanner = new Scanner(System.in);
    for (; ; ) {
        System.out.println("Enter user name whose counter is to be incremented:");
        String aName = aScanner.nextLine();
        Counter aCounter = (Counter) DirectedRPCProxyGenerator.generateRPCProxy((DuplexRPCSessionPort) mainPort, aName, ACounter.class, null);
        aCounter.increment(1);
        System.out.println("New counter value:" + aCounter.getValue());
    }
}
Also used : Scanner(java.util.Scanner) Counter(examples.mvc.local.duplex.Counter) ACounter(examples.mvc.local.duplex.ACounter) ACounter(examples.mvc.local.duplex.ACounter) DuplexRPCSessionPort(sessionport.rpc.duplex.DuplexRPCSessionPort)

Aggregations

Counter (examples.mvc.local.duplex.Counter)2 ACounter (examples.mvc.local.duplex.ACounter)1 LocateRegistry (java.rmi.registry.LocateRegistry)1 Registry (java.rmi.registry.Registry)1 Scanner (java.util.Scanner)1 DuplexRPCSessionPort (sessionport.rpc.duplex.DuplexRPCSessionPort)1