本文整理汇总了Java中java.rmi.registry.Registry.lookup方法的典型用法代码示例。如果您正苦于以下问题:Java Registry.lookup方法的具体用法?Java Registry.lookup怎么用?Java Registry.lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.registry.Registry
的用法示例。
在下文中一共展示了Registry.lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRemoteObjectWithUIDHack
import java.rmi.registry.Registry; //导入方法依赖的package包/类
/*******************
* Hack to retrieve an RMI object where the remote serialVersionUID does
* not match the serialVersionUID of the local class.
*
* Here we request the remote object through a proxy. When the object data
* comes back over the proxy, we update serialVersionUID fields at the
* network level so that they match those of the local classes.
*
* This hack makes BaRMIe attacks compatible with multiple versions of
* target applications without having to recompile the code with the
* required serialVersionUID.
*
* @param ep An enumerated RMI endpoint.
* @param objectName The name of the object to look up.
* @return The remote object reference.
* @throws BaRMIeGetObjectException If there was a problem retrieving the requested object.
******************/
private Object getRemoteObjectWithUIDHack(RMIEndpoint ep, String objectName) throws BaRMIeGetObjectException {
RMIObjectUIDFixingProxy proxy = null;
Registry reg;
Object obj;
try {
//Start a UID fixing proxy
proxy = new RMIObjectUIDFixingProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options);
proxy.startProxy();
//Get an RMI registry reference which points at our UID fixing proxy
reg = LocateRegistry.getRegistry(proxy.getServerListenAddress().getHostAddress(), proxy.getServerListenPort());
//Request the remote object through the proxy and return it
obj = reg.lookup(objectName);
return obj;
} catch(Exception ex) {
throw new BaRMIeGetObjectException("Failed to lookup a remote object via RMIObjectUIDFixingProxy.", ex);
} finally {
//Stop proxy
if(proxy != null) {
proxy.stopProxy(true);
}
}
}
示例2: getRemoteScheduler
import java.rmi.registry.Registry; //导入方法依赖的package包/类
protected RemotableQuartzScheduler getRemoteScheduler()
throws SchedulerException {
if (rsched != null) {
return rsched;
}
try {
Registry registry = LocateRegistry.getRegistry(rmiHost, rmiPort);
rsched = (RemotableQuartzScheduler) registry.lookup(schedId);
} catch (Exception e) {
SchedulerException initException = new SchedulerException(
"Could not get handle to remote scheduler: "
+ e.getMessage(), e);
throw initException;
}
return rsched;
}
示例3: getItfAgteReactRemoto
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static ItfUsoAgenteReactivo getItfAgteReactRemoto(String host, int puerto, String nombreAgente) throws java.rmi.RemoteException {
Registry regCliente = LocateRegistry.getRegistry(host, puerto);
ItfUsoAgenteReactivo agenteRemoto = null;
// ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
try {
if (regCliente == null) {
System.err.println("buscarAgenteRemoto regCliente == null");
if (trazas != null)
trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "No consigo encontrar al agente: "+
nombreAgente + " en Host :" + host + " puerto:" + puerto, NivelTraza.error));
}
agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
return agenteRemoto;
} catch (Exception ex) {
System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
if (trazas != null)
trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "No consigo encontrar al agente: "+
nombreAgente + " en Host :" + host + " puerto:" + puerto, NivelTraza.debug));
// Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
示例4: getRemoteEntityFromHost
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static Remote getRemoteEntityFromHost(String host, int puerto, String identEntity) throws java.rmi.RemoteException {
Registry regCliente = LocateRegistry.getRegistry(host, puerto);
Object remoteEntity = null;
// ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
try {
if (regCliente == null) {
// System.err.println("buscarAgenteRemoto regCliente == null");
// if (trazas != null)
trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
identEntity + " No se consigue encontrar el registro RMI del Host :" + host + " puerto:" + puerto, NivelTraza.debug));
}
return regCliente.lookup(identEntity);
} catch (Exception ex) {
System.err.println("Fallo buscaAgenteRemoto\n"+ ex.getMessage());
trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", " No se puede obtener la entidad : "+
identEntity + " No se consigue encontrar el registro RMI del Host :" + host + " puerto:"+ puerto , NivelTraza.debug));
// Logger.getLogger(ComunicacionAgentes.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
示例5: inheritedChannel
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public synchronized Channel inheritedChannel() throws IOException {
System.err.println("SP.inheritedChannel");
if (channel == null) {
channel = SocketChannel.open();
Socket socket = channel.socket();
System.err.println("socket = " + socket);
/*
* Notify test that inherited channel was created.
*/
try {
System.err.println("notify test...");
int registryPort = Integer.getInteger(
"test.java.rmi.rmidViaInheritedChannel.registry.port", 0);
Registry registry = LocateRegistry.getRegistry(registryPort);
Callback obj = (Callback) registry.lookup("Callback");
obj.notifyTest();
} catch (NotBoundException nbe) {
throw (IOException)
new IOException("callback object not bound").
initCause(nbe);
}
}
return channel;
}
示例6: getRemoteScheduler
import java.rmi.registry.Registry; //导入方法依赖的package包/类
protected RemotableQuartzScheduler getRemoteScheduler()
throws SchedulerException {
if (rsched != null) {
return rsched;
}
try {
Registry registry = LocateRegistry.getRegistry(rmiHost, rmiPort);
rsched = (RemotableQuartzScheduler) registry.lookup(schedId);
} catch (Exception e) {
SchedulerException initException = new SchedulerException(
"Could not get handle to remote scheduler: "
+ e.getMessage(), e);
initException
.setErrorCode(SchedulerException.ERR_COMMUNICATION_FAILURE);
throw initException;
}
return rsched;
}
示例7: inheritedChannel
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public synchronized Channel inheritedChannel() throws IOException {
System.err.println("SP.inheritedChannel");
if (channel == null) {
channel = SocketChannel.open();
Socket socket = channel.socket();
System.err.println("socket = " + socket);
/*
* Notify test that inherited channel was created.
*/
try {
System.err.println("notify test...");
Registry registry =
LocateRegistry.getRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT);
Callback obj = (Callback) registry.lookup("Callback");
obj.notifyTest();
} catch (NotBoundException nbe) {
throw (IOException)
new IOException("callback object not bound").
initCause(nbe);
}
}
return channel;
}
示例8: main
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port"));
Registry registry =
LocateRegistry.getRegistry("", registryPort);
ShutdownMonitor monitor = (ShutdownMonitor)
registry.lookup(KeepAliveDuringCall.BINDING);
System.err.println("(ShutdownImpl) retrieved shutdown monitor");
impl = new ShutdownImpl(monitor);
Shutdown stub = (Shutdown) UnicastRemoteObject.exportObject(impl);
System.err.println("(ShutdownImpl) exported shutdown object");
monitor.submitShutdown(stub);
System.err.println("(ShutdownImpl) submitted shutdown object");
} catch (Exception e) {
System.err.println("(ShutdownImpl) TEST SUBPROCESS FAILURE:");
e.printStackTrace();
}
}
示例9: connectServer
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public void connectServer() {
try
{
Registry reg=LocateRegistry.getRegistry("localhost",5040);
serverAddress = (ServerInterface) reg.lookup("LionKing");
System.out.println("Connected to Server");
}catch(Exception e)
{
System.out.println(e);
}
}
示例10: getProxiedObjectWithUIDHack
import java.rmi.registry.Registry; //导入方法依赖的package包/类
/*******************
* Chain a full RMI proxy to a serialVersionUID fixing proxy in order to
* retrieve a fully proxied remote object reference even if the
* serialVersionUID does not match that of the local class.
*
* @param ep An enumerated RMI endpoint.
* @param name The name of the object to look up.
* @param payload The raw bytes of the deserialization payload to use.
* @param marker The bytes that the method call proxy should replace with the payload bytes.
* @return The remote object reference.
******************/
private final Object getProxiedObjectWithUIDHack(RMIEndpoint ep, String name, byte[] payload, byte[] marker) throws BaRMIeException {
RMIObjectUIDFixingProxy uidFixer = null;
RMIObjectProxy objProxy;
Registry reg;
Object obj = null;
try {
//Start a UID fixing proxy
uidFixer = new RMIObjectUIDFixingProxy(InetAddress.getByName(ep.getEndpoint().getHost()), ep.getEndpoint().getPort(), this._options);
uidFixer.startProxy();
this._proxies.add(uidFixer);
//Start an RMI object proxy and chain it to the UID fixing proxy
objProxy = new RMIObjectProxy(uidFixer.getServerListenAddress(), uidFixer.getServerListenPort(), this._options, payload, marker);
objProxy.startProxy();
this._proxies.add(objProxy);
//Retrieve a proxied RMI registry instance
reg = LocateRegistry.getRegistry(objProxy.getServerListenAddress().getHostAddress(), objProxy.getServerListenPort());
//Lookup the target remote object
obj = reg.lookup(name);
} catch(Exception ex) {
throw new BaRMIeGetObjectException("Failed to retrieve proxied object using serialVersionUID hack.", ex);
}
//Return the remote object
return obj;
}
示例11: testStub
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public String testStub() throws Exception {
try {
Registry registry = LocateRegistry.getRegistry(port);
Hello stub = (Hello) registry.lookup("Hello");
String response = stub.sayHello();
return response;
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
throw e;
}
}
示例12: getItfGestionEntidadRemota
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static InterfazGestion getItfGestionEntidadRemota(String identHost, String identEntity) throws RemoteException, NotBoundException {
Registry regCliente = LocateRegistry.getRegistry(identHost);
InterfazGestion itfGesagenteRemoto = null;
if (regCliente == null) return null;
Remote objInRegistry = regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
if (objInRegistry != null) itfGesagenteRemoto = (InterfazGestion) objInRegistry;
return itfGesagenteRemoto;
// return (InterfazGestion)regCliente.lookup(NombresPredefinidos.ITF_GESTION+identEntity);
}
示例13: main
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
int registryPort =
Integer.parseInt(System.getProperty("rmi.registry.port"));
Registry registry =
LocateRegistry.getRegistry("", registryPort);
Remote stub = registry.lookup(LeaseCheckInterval.BINDING);
Runtime.getRuntime().halt(0);
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: getItfUsoRecursoRemoto
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static Remote getItfUsoRecursoRemoto(String identHost, String nombreRecurso) throws RemoteException, NotBoundException {
Registry regCliente = LocateRegistry.getRegistry(identHost);
InterfazGestion agenteRemoto = null;
if (regCliente == null) return null;
else
// agenteRemoto = (ItfUsoAgenteReactivo) regCliente.lookup(nombreAgente);
// return agenteRemoto;
// }
return regCliente.lookup(NombresPredefinidos.ITF_USO+nombreRecurso);
}
示例15: startLocator
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private static int startLocator(Registry registry) throws IOException, NotBoundException {
RemoteDUnitVMIF remote = (RemoteDUnitVMIF) registry.lookup("vm" + LOCATOR_VM_NUM);
final File locatorLogFile =
LOCATOR_LOG_TO_DISK ? new File("locator-" + locatorPort + ".log") : new File("");
MethExecutorResult result = remote.executeMethodOnObject(new SerializableCallable() {
public Object call() throws IOException {
Properties p = getDistributedSystemProperties();
// I never want this locator to end up starting a jmx manager
// since it is part of the unit test framework
p.setProperty(JMX_MANAGER, "false");
// Disable the shared configuration on this locator.
// Shared configuration tests create their own locator
p.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");
// Tell the locator it's the first in the system for
// faster boot-up
System.setProperty(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY, "true");
// disable auto-reconnect - tests fly by so fast that it will never be
// able to do so successfully anyway
p.setProperty(DISABLE_AUTO_RECONNECT, "true");
try {
Locator.startLocatorAndDS(0, locatorLogFile, p);
InternalLocator internalLocator = (InternalLocator) Locator.getLocator();
locatorPort = internalLocator.getPort();
internalLocator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
} finally {
System.getProperties().remove(GMSJoinLeave.BYPASS_DISCOVERY_PROPERTY);
}
return locatorPort;
}
}, "call");
if (result.getException() != null) {
RuntimeException ex = new RuntimeException("Failed to start locator", result.getException());
ex.printStackTrace();
throw ex;
}
return (Integer) result.getResult();
}