Package java.rmi.registry

Examples of java.rmi.registry.Registry


  public static void main(String[] args) throws Throwable
  {
    if (GameServerImpl.startDaemon(false))
    {
      Registry registry = LocateRegistry.getRegistry("127.0.0.1");
     
      GameServer gameServer = (GameServer) registry.lookup(GameServer.STUB_NAME);
     
      HumanGameClient playerClient = new HumanGameClient(gameServer, gameServer.getTicket(), "Julek");
      playerClient.addObserver(new SimpleObserver());
      new Thread(playerClient).start();
      new Thread(new AIGameClient(gameServer, gameServer.getTicket(), "bougo", new DefaultEvalScore(), 4)).start();
View Full Code Here


  {
    try
    {
      serverInstance = new GameServerImpl("local", debugMode, new DefaultGamePlayerProvider());
           
      Registry registry = MiscUtils.initRMIServer(1099);
     
      // Ensure compliancy with previous JVM versions.
      GameServer stub = (GameServer) UnicastRemoteObject.exportObject(serverInstance);
      registry.rebind(STUB_NAME, stub);
           
      System.out.println("Game daemon started !");
           
      return true;
    }
View Full Code Here

 
  public static void main(String[] args) throws Throwable
  {
    if (startDaemon(true))
    {
      Registry registry = LocateRegistry.getRegistry("127.0.0.1");
     
      GameServer gameServer = (GameServer) registry.lookup(STUB_NAME);
     
      GameClient firstClient = new AIGameClient(gameServer, gameServer.getTicket(), "bougo", new DefaultEvalScore(), 4);
     
      new Thread(firstClient).start();
      new Thread(new AIGameClient(gameServer, gameServer.getTicket(), "bougoéland", new DefaultEvalScore(), 4)).start();
View Full Code Here

   * @throws NotBoundException if the remote server
   * does not contain the expected global server.
   */
  private GlobalServer getGlobalServer() throws RemoteException, NotBoundException
  {
    Registry registry = LocateRegistry.getRegistry(remoteServerAddress);
    return (GlobalServer) registry.lookup(GlobalServer.STUB_NAME);
  }
View Full Code Here

   
    try
    {
      globalServer.createGame(gameName);
     
      Registry registry = LocateRegistry.getRegistry(remoteServerAddress);
      gameServer = (GameServer) registry.lookup(GlobalServer.SINGLE_GAME_SERVER_STUB_PREFIX + gameName);
     
    }
    catch (RemoteException e)
    {
      JOptionPane.showMessageDialog(this, GUIMessages.UNABLE_TO_CONNECT_TO_SERVER_MESSAGE + e.getMessage(), GUIMessages.ERROR_TEXT.toString(), JOptionPane.ERROR_MESSAGE);
View Full Code Here

   
    GameServer gameServer = null;
   
    try
    {
      Registry registry = LocateRegistry.getRegistry(remoteServerAddress);
      gameServer = (GameServer) registry.lookup(GlobalServer.SINGLE_GAME_SERVER_STUB_PREFIX + gameName);
     
      if (gameServer.getPlayers().size() == PlayerMark.getNumberOfPlayerMarks())
      {
        JOptionPane.showMessageDialog(this, GUIMessages.THE_SELECTED_GAME_IS_FULL, GUIMessages.ERROR_TEXT.toString(), JOptionPane.ERROR_MESSAGE);       
        return;
View Full Code Here

    }

    public void registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
        RMIURI rmiURI = new RMIURI(uri);
       
        Registry registry;
        try {
            registry = rmiRegistries.get(Integer.toString(rmiURI.port));
            if (registry == null) {
                try {
                    registry = LocateRegistry.getRegistry(rmiURI.port);
                    registry.lookup(rmiURI.serviceName);
                } catch (RemoteException e) {
                    registry = LocateRegistry.createRegistry(rmiURI.port);
                } catch (NotBoundException e) {
                    // Ignore
                }
                rmiRegistries.put(Integer.toString(rmiURI.port), registry);
            }
            registry.bind(rmiURI.serviceName, serviceObject);
        } catch (AlreadyBoundException e) {
            throw new RMIHostException(e);
        } catch (RemoteException e) {
            RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
            rmiExec.setStackTrace(e.getStackTrace());
View Full Code Here

    public void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException {
        RMIURI rmiURI = new RMIURI(uri);

        try {
            Registry registry = rmiRegistries.get(Integer.toString(rmiURI.port));
            if (registry == null) {
                registry = LocateRegistry.getRegistry(rmiURI.port);
                rmiRegistries.put(Integer.toString(rmiURI.port), registry);
            }
            registry.unbind(rmiURI.serviceName);
        } catch (RemoteException e) {
            RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
            rmiExec.setStackTrace(e.getStackTrace());
            throw rmiExec;
        } catch (NotBoundException e) {
View Full Code Here

       
        Remote remoteService = null;
        try {
            // Requires permission java.net.SocketPermission "host:port", "connect,accept,resolve"
            // in security policy.
            Registry registry = LocateRegistry.getRegistry(rmiURI.host, rmiURI.port);

            if (registry != null) {
                remoteService = registry.lookup(rmiURI.serviceName);
            }
        } catch (RemoteException e) {
            RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
            rmiExec.setStackTrace(e.getStackTrace());
            throw rmiExec;
View Full Code Here

            executeTaskWithDefaultCardManager(task, allowDummySC, helloMsg, useOldCommandLineStyle);
            return;
        }
        System.out.println("codebase: " + System.getProperty("java.rmi.server.codebase"));
        String serverAddress = InetAddress.getLocalHost().getHostAddress();
        Registry registry = LocateRegistry.getRegistry(serverAddress);

        try {
            //list bounded name in this registry: if rmiregistry is not running, this will throw an exception
            String[] a = registry.list();
            for (int i = 0; i < a.length; i++) {
                System.out.println(a[i]);
            }

        } catch (Exception e) {   //need to start card reader manager
            System.out.println(e.getMessage());
            //start basic card reader manager in this process
            System.out.println("-->start default card reader manager in this process\n");
            executeTaskWithDefaultCardManager(task, allowDummySC, helloMsg, requireConfirmationToDisconnect, useOldCommandLineStyle);
            return;
            //start it as rmi server
                /*System.out.println("start default card manager");
            startDefaultCardManager();
            registry = LocateRegistry.getRegistry(serverAddress);*/
        }
        try {

            reader = (SmartCardTaskProcessor) registry.lookup(SmartCardTaskProcessor.registryId);
            reader.exist();//if card reader manager is not running, this will throw an exception
            } catch (Exception ex) {
            System.out.println("Exception: " + ex.getMessage());
            System.out.println("start default card manager\n");
            startDefaultCardManager();
            try {
                reader = (SmartCardTaskProcessor) registry.lookup(SmartCardTaskProcessor.registryId);
            } catch (RemoteException ex1) {
                Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex1);
            } catch (NotBoundException ex1) {
                Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex1);
            }
View Full Code Here

TOP

Related Classes of java.rmi.registry.Registry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.