Search code examples
javarmi

JAVA RMI Can i register multiple remote objects into one registry with different name?


On server side, Route is the remote interface and i am binding 3 remote objects into one registry.

Would this be possible to use?

 try {

        Route c = new Journey("Cork", "Dublin", "2:44");
        Route g = new Journey("Galway", "Dublin", "2:44");
        Route b = new Journey("Bray", "Dublin", "0:44");

        Route stub1 = (Route) UnicastRemoteObject.exportObject(c,0);
        Route stub2 = (Route) UnicastRemoteObject.exportObject(g,0);
        Route stub3 = (Route) UnicastRemoteObject.exportObject(b,0);
        Registry registry = LocateRegistry.createRegistry(1109);
        registry.bind("Cork", stub1);
        registry.bind("Galway", stub2);
        registry.bind("Bray", stub3);

        System.out.println("Routes are registered.");

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

Allow the client to book a journey. You should not be able to double book a reservation. This application should have a minimum of 3 journeys to choose from. Each journey should be allowed to have 3 bookings


Solution

  • JAVA RMI Can i register multiple remote objects into one registry with different name?

    Yes.

    However you can see that instead of waiting 18 hours and having to put up with a lot of uninformed comments, it would have been considerably more efficient just to try it.