當前位置: 首頁>>代碼示例>>Java>>正文


Java Registry.rebind方法代碼示例

本文整理匯總了Java中java.rmi.registry.Registry.rebind方法的典型用法代碼示例。如果您正苦於以下問題:Java Registry.rebind方法的具體用法?Java Registry.rebind怎麽用?Java Registry.rebind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.rmi.registry.Registry的用法示例。


在下文中一共展示了Registry.rebind方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addElement2RegRMI

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static boolean addElement2RegRMI(String identHost, String element, Remote obj) {
//      String registroAqSeAgnade = "registroRMIOrganizacion"  ;
      try {
            if (identHost !=null  ){
                     Registry identHostRegistry = LocateRegistry.getRegistry(identHost);
                     if (identHostRegistry != null){
                         identHostRegistry.rebind(element, obj);
                        logger.error("Se añade la interfaz : " +element +  " en el registro del  nodo --: "+identHost   );
                        trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
						"Se añade la interfaz : " +element +  " en el registro del  nodo --: "+identHost   ,
						InfoTraza.NivelTraza.debug));
                        return true;
                    }else{ // No se ha podido obtener un registro RMI para ese host
                            logger.error("Error al  obtener el RMI registro del host --: "+ identHost + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
                            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
						"Error al  obtener el RMI registro del host-- "+ identHost + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
						InfoTraza.NivelTraza.debug));

                    }
            }
            return false;
      } catch (Exception e) {
            logger.error("Error al añadir un elemento en el registro RMI del host --: "+ identHost + " Es posible que no se haya creado: Revisar la descripcion de la organizacion" );
            trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI",
						"Error al añadir un elemento en el registro RMI del host -- "+ identHost + "-- Es posible que no se haya creado: Revisar la descripcion de la organizacion" ,
						InfoTraza.NivelTraza.error));
               return false;
            }
        }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:30,代碼來源:AdaptadorRegRMI.java

示例2: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) {
   /*
    MarioNOTE:
    creating a connection to the database
    */
   DatabaseConnection connection = new DatabaseConnection("java", "password");
   
   try{
       int port = 1099;
       /*
       MarioNOTE:
       creating a Registry that allows the server to
       publish a service and client to retrieve the proxy
       */
       Registry registry = LocateRegistry.createRegistry(port);
       DatabaseGestion DBGestor = new DatabaseGestion();
       registry.rebind("MyDatabase", DBGestor);
       
       System.out.println("\nServer is ready...");
       
   }catch(RemoteException ex){
       System.out.println("\nRMIDatabaseServer ERROR: " + ex);
   }
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-M,代碼行數:25,代碼來源:RMIDatabaseServer.java

示例3: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    String[] names = {
        "fairly:simple", "somewhat:more/complicated",
        "multiple:colons:in:name"
    };

    Registry reg = TestLibrary.createRegistryOnUnusedPort();
    int port = TestLibrary.getRegistryPort(reg);

    for (int i = 0; i < names.length; i++) {
        reg.rebind(names[i], reg);
        Naming.lookup("rmi://localhost:" + port + "/" + names[i]);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:LookupNameWithColon.java

示例4: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnUnusedPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:41,代碼來源:UnderscoreHost.java

示例5: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Registry impl = TestLibrary.createRegistryOnUnusedPort();
    Registry stub = (Registry) RemoteObject.toStub(impl);
    stub.bind("", stub);
    stub.lookup("");
    stub.rebind("", stub);
    stub.lookup("");
    stub.unbind("");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:EmptyName.java

示例6: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Registry registry = TestLibrary.createRegistryOnUnusedPort();
    int registryPort = TestLibrary.getRegistryPort(registry);
    Registry reg = LocateRegistry.getRegistry("", registryPort);
    FooImpl fooimpl = new FooImpl();
    UnicastRemoteObject.exportObject(fooimpl, 0);
    reg.rebind("foo", fooimpl);
    Foo foostub = (Foo) reg.lookup("foo");
    FooImpl fooimpl2 = new FooImpl();
    UnicastRemoteObject.exportObject(fooimpl2, 0);
    foostub.echo(fooimpl2);
    UnicastRemoteObject.unexportObject(fooimpl, true);
    UnicastRemoteObject.unexportObject(fooimpl2, true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:NoConsoleOutput.java

示例7: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    String[] names = {
        "fairly:simple", "somewhat:more/complicated",
        "multiple:colons:in:name"
    };

    Registry reg = TestLibrary.createRegistryOnEphemeralPort();
    int port = TestLibrary.getRegistryPort(reg);

    for (int i = 0; i < names.length; i++) {
        reg.rebind(names[i], reg);
        Naming.lookup("rmi://localhost:" + port + "/" + names[i]);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:LookupNameWithColon.java

示例8: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnEphemeralPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:UnderscoreHost.java

示例9: main

import java.rmi.registry.Registry; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Registry impl = TestLibrary.createRegistryOnEphemeralPort();
    Registry stub = (Registry) RemoteObject.toStub(impl);
    stub.bind("", stub);
    stub.lookup("");
    stub.rebind("", stub);
    stub.lookup("");
    stub.unbind("");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:EmptyName.java

示例10: rebind

import java.rmi.registry.Registry; //導入方法依賴的package包/類
private void rebind() throws RemoteException {
    Registry registry = getRegistry();
    registry.rebind(this.name, this.remote);
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:5,代碼來源:RmiBinder.java


注:本文中的java.rmi.registry.Registry.rebind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。