Search in sources :

Example 1 with DistributedRMICounter

use of examples.mvc.rmi.duplex.DistributedRMICounter in project GIPC by pdewan.

the class AGIPCCounterClient method test.

public static void test(GIPCRegistry gipcRegistry, Class aLookedupClass) {
    DistributedRMICounter counter11 = (DistributedRMICounter) gipcRegistry.lookup(aLookedupClass, COUNTER1);
    DistributedRMICounter counter12 = (DistributedRMICounter) gipcRegistry.lookup(aLookedupClass, COUNTER1);
    DistributedRMICounter counter2 = (DistributedRMICounter) gipcRegistry.lookup(aLookedupClass, COUNTER2);
    AnRMICounterClient.doOperations(counter11, counter12, counter2);
}
Also used : DistributedRMICounter(examples.mvc.rmi.duplex.DistributedRMICounter)

Example 2 with DistributedRMICounter

use of examples.mvc.rmi.duplex.DistributedRMICounter in project GIPC by pdewan.

the class ACounterSessionMember method doOperations.

public static void doOperations() {
    try {
        Set<String> aMembers = gipcRegistry.getAllMembers();
        for (String aMember : aMembers) {
            DistributedRMICounter aMemberCounter = (DistributedRMICounter) gipcRegistry.lookup(aMember, COUNTER_NAME);
            aMemberCounter.increment(Integer.parseInt(aMember));
        }
        DistributedRMICounter anAllRemoteCounter = (DistributedRMICounter) gipcRegistry.lookupAllRemote(COUNTER_NAME);
        // anAllRemoteCounter.increment(2);
        System.out.println("All remote counter values:" + anAllRemoteCounter.getValue());
        DistributedRMICounter anAllRemoteAndMeCounter = (DistributedRMICounter) gipcRegistry.lookupAll(COUNTER_NAME);
        // anAllRemoteCounter.increment(2);
        System.out.println("All remote and me counter values:" + anAllRemoteAndMeCounter.getValue());
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}
Also used : DistributedRMICounter(examples.mvc.rmi.duplex.DistributedRMICounter) RemoteException(java.rmi.RemoteException)

Example 3 with DistributedRMICounter

use of examples.mvc.rmi.duplex.DistributedRMICounter in project GIPC by pdewan.

the class AnRMICounterClient method main.

public static void main(String[] args) {
    try {
        Registry rmiRegistry = LocateRegistry.getRegistry();
        DistributedRMICounter counter11 = (DistributedRMICounter) rmiRegistry.lookup(COUNTER1);
        DistributedRMICounter counter12 = (DistributedRMICounter) rmiRegistry.lookup(COUNTER1);
        DistributedRMICounter counter2 = (DistributedRMICounter) rmiRegistry.lookup(COUNTER2);
        doOperations(counter11, counter12, counter2);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DistributedRMICounter(examples.mvc.rmi.duplex.DistributedRMICounter) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 4 with DistributedRMICounter

use of examples.mvc.rmi.duplex.DistributedRMICounter in project GIPC by pdewan.

the class AnRMIRepositoryClientLauncher method main.

public static void main(String[] args) {
    try {
        Registry rmiRegistry = LocateRegistry.getRegistry();
        RemoteRepository counterRepository = (RemoteRepository) rmiRegistry.lookup(COUNTER_REPOSITORY);
        DistributedRMICounter exportedCounter = new ADistributedInheritingRMICounter();
        UnicastRemoteObject.exportObject(exportedCounter, 0);
        counterRepository.deposit(exportedCounter);
        exportedCounter.increment(1);
        List<Remote> objects = counterRepository.getObjects();
        for (Remote counter : objects) {
            System.out.println(((DistributedRMICounter) counter).getValue());
            System.out.println(counter == exportedCounter);
            System.out.println(counter.equals(exportedCounter));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DistributedRMICounter(examples.mvc.rmi.duplex.DistributedRMICounter) ADistributedInheritingRMICounter(examples.mvc.rmi.duplex.ADistributedInheritingRMICounter) Remote(java.rmi.Remote) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Example 5 with DistributedRMICounter

use of examples.mvc.rmi.duplex.DistributedRMICounter in project GIPC by pdewan.

the class RemoteCounterClientLauncher method main.

public static void main(String[] args) {
    try {
        Registry rmiRegistry = LocateRegistry.getRegistry();
        DistributedRMICounter counter = (DistributedRMICounter) rmiRegistry.lookup(DistributedRMICounter.class.getName());
        System.out.println(counter.getValue());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DistributedRMICounter(examples.mvc.rmi.duplex.DistributedRMICounter) LocateRegistry(java.rmi.registry.LocateRegistry) Registry(java.rmi.registry.Registry)

Aggregations

DistributedRMICounter (examples.mvc.rmi.duplex.DistributedRMICounter)11 LocateRegistry (java.rmi.registry.LocateRegistry)8 Registry (java.rmi.registry.Registry)8 ADistributedInheritingRMICounter (examples.mvc.rmi.duplex.ADistributedInheritingRMICounter)4 ADistributedDelegatingRMICounter (examples.mvc.rmi.duplex.ADistributedDelegatingRMICounter)1 GIPCRegistry (inputport.rpc.GIPCRegistry)1 Remote (java.rmi.Remote)1 RemoteException (java.rmi.RemoteException)1