Package java.rmi.registry

Examples of java.rmi.registry.Registry


   {
     log.info("kill() invoked - first deregistering from the rmi registry");

      // unregister myself from the RMI registry

      Registry registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);

      String name = RMI_SERVER_PREFIX + server.getServerID();
      registry.unbind(name);
      log.info("unregistered " + name + " from registry");

      // unregister myself from the RMI registry

      name = NAMING_SERVER_PREFIX + server.getServerID();
      registry.unbind(name);
      log.info("unregistered " + name + " from registry");

      log.info("Killing VM!!!!");
     
      Runtime.getRuntime().halt(1);
View Full Code Here


            String host = home.host;
            int port = home.port;
            locator.setHomeInUse(home);
            storeLocalConfig(configuration);
            log.debug(this + " looking up registry: " + host + "," + port);
            Registry registry = LocateRegistry.getRegistry(host, registryPort);
            log.debug(this + " trying to connect to: " + home);
            Remote remoteObj = registry.lookup("remoting/RMIServerInvoker/" + port);
            log.debug("Remote RMI Stub: " + remoteObj);
            setServerStub((RMIServerInvokerInf) remoteObj);
            connected = true;
            break;
         }
View Full Code Here

      return server;
   }
  
   protected void initRMI(Home bindHome, Home connectHome) throws IOException
   {
      Registry registry = null;
      try
      {
         registry = getRegistry();
      }
      catch (Exception e)
      {
         throw new IOException(e.getMessage());
      }

      String bindHost = bindHome.host;
      int bindPort = bindHome.port;
      String clientConnectHost = connectHome.host;

      if(clientConnectHost == null)
      {
         clientConnectHost = bindHost;
      }

      locator.setHomeInUse(bindHome);
      RMIServerSocketFactory ssf = new RemotingRMIServerSocketFactory(getServerSocketFactory(), BACKLOG_DEFAULT, bindHost, getTimeout());
      csf = getRMIClientSocketFactory(clientConnectHost);
      stub = UnicastRemoteObject.exportObject(this, bindPort, csf, ssf);

      log.debug("Binding server to \"remoting/RMIServerInvoker/" + bindPort + "\" in registry");
      registry.rebind("remoting/RMIServerInvoker/" + bindPort, this);

      unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), this.getClass().getClassLoader());
      marshaller = MarshalFactory.getMarshaller(getLocator(), this.getClass().getClassLoader());
   }
View Full Code Here

      super(locator, configuration);
   }

   private Registry getRegistry() throws Exception
   {
      Registry registry = null;

      int port = DEFAULT_REGISTRY_PORT;

      // See if locator contains a specific registry port
      Map params = getConfiguration();
View Full Code Here

      {
         try
         {
            log.debug("locator: " + locator + ", home: " + locator.getHomeInUse());
            log.debug(this + " primary: " + isPrimaryServer + " unbinding " + "remoting/RMIServerInvoker/" + locator.getPort() + " from registry");
            Registry registry = getRegistry();
            registry.unbind("remoting/RMIServerInvoker/" + locator.getPort());
            log.debug("unbound " + "remoting/RMIServerInvoker/" + locator.getPort() + " from registry");
         }
         catch(Exception e)
         {
            if ("Finalizer".equalsIgnoreCase(Thread.currentThread().getName()))
View Full Code Here

      try
      {
         int serverId = getServerPeer(target).getServerPeerID();

         //First unregister from the RMI registry
         Registry registry = LocateRegistry.getRegistry(RMITestServer.DEFAULT_REGISTRY_PORT);

         String name = RMITestServer.RMI_SERVER_PREFIX + serverId;
         registry.unbind(name);
         log.info("unregistered " + name + " from registry");

         name = RMITestServer.NAMING_SERVER_PREFIX + serverId;
         registry.unbind(name);
         log.info("unregistered " + name + " from registry");

         log.info("#####");
         log.info("#####");
         log.info("##### Halting the server!");
View Full Code Here

        mbserver = ManagementFactory.getPlatformMBeanServer();
        int port = Integer.parseInt(System.getProperty(
            Constants.XMEMCACHED_RMI_PORT, "7077"));
        String rmiName = System.getProperty(
            Constants.XMEMCACHED_RMI_NAME, "xmemcachedServer");
        Registry registry = null;
        try {
          registry = LocateRegistry.getRegistry(port);
          registry.list();
        } catch (Exception e) {
          registry = null;
        }
        if (null == registry) {
          registry = LocateRegistry.createRegistry(port);
        }
        registry.list();
        String serverURL = "service:jmx:rmi:///jndi/rmi://" + host
            + ":" + port + "/" + rmiName;
        JMXServiceURL url = new JMXServiceURL(serverURL);
        connectorServer = JMXConnectorServerFactory
            .newJMXConnectorServer(url, null, mbserver);
View Full Code Here

            System.out.println("codebase: " + System.getProperty("java.rmi.server.codebase"));
            String serverAddress = InetAddress.getLocalHost().getHostAddress();
            System.setProperty("java.rmi.server.hostname", serverAddress);

            SmartCardTaskProcessor stub = (SmartCardTaskProcessor) UnicastRemoteObject.exportObject(engine, 0);
            Registry registry = LocateRegistry.getRegistry();

            boolean rmiregistryFound=true;
            try{
                //list bounded name in this registry: if rmiregistry is not running, this will throw an exception
                System.out.println("try to get registry list");
                String []a=registry.list();
                System.out.println(a.length + " names bound in the registry");
                for(int i=0;i<a.length;i++)
                    System.out.println(i+"\t"+a[i]);
            }catch(Exception e)
            {   //need to start rmiregistry
                rmiregistryFound=false;
                String rmiRegistryPath=AFileUtilities.appendToPath(System.getProperty("java.home"),"bin");
                rmiRegistryPath=AFileUtilities.appendToPath(rmiRegistryPath,"rmiregistry");
                ProcessBuilder processBuilder=new ProcessBuilder(rmiRegistryPath);
                System.out.println("Start rmiregistry");
                rmiRegistryProcess = processBuilder.start();
                System.out.println("rmiregistry started");
            }

            long start=System.currentTimeMillis();
            while(false==rmiregistryFound){
                System.out.println("waiting for registry");
                long now=System.currentTimeMillis();
                if(now-start>1000) throw new RuntimeException("rmiregistry is not responsive");

                try{
                    registry = LocateRegistry.getRegistry();
                    //list bounded name in this registry: if rmiregistry is not running, this will throw an exception
                    String []a=registry.list();
                    System.out.println(a.length + " names bound in the registry:");
                    for(int i=0;i<a.length;i++)
                        System.out.println(a[i]);
                    rmiregistryFound=true;
                }catch(Exception e)
                {   //need to start rmiregistry
                    System.out.println("registry not found");
                    Thread.yield();
                }
            }
            registry.rebind(SmartCardTaskProcessor.registryId, stub);
            System.out.println("Terminal Manager bound");

            System.out.println("wait for task or command");

        } catch (Exception ex) {
View Full Code Here

   
    GameServer gameServer = null;
   
    try
    {
      Registry registry = LocateRegistry.getRegistry(serverHost);
      gameServer = (GameServer) registry.lookup(GameServer.STUB_NAME);
    }
    catch (Throwable t)
    {
      JOptionPane.showMessageDialog(this, GUIMessages.UNABLE_TO_CONNECT_TO_SERVER_MESSAGE + t.getMessage(), GUIMessages.ERROR_TEXT.toString(), JOptionPane.ERROR_MESSAGE);
      t.printStackTrace();
View Full Code Here

         
          // Then swaps the security manager...
          SecurityManager manager = System.getSecurityManager();         
          System.setSecurityManager(new SecurityManager());
         
          Registry registry = null;
         
          // Creates the registry
          try
          {
            registry = LocateRegistry.createRegistry(port);
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.