本文整理匯總了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;
}
}
示例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);
}
}
示例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]);
}
}
示例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);
}
}
示例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("");
}
示例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);
}
示例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]);
}
}
示例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);
}
}
示例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("");
}
示例10: rebind
import java.rmi.registry.Registry; //導入方法依賴的package包/類
private void rebind() throws RemoteException {
Registry registry = getRegistry();
registry.rebind(this.name, this.remote);
}