本文整理汇总了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);
}