本文整理汇总了Java中java.rmi.registry.Registry.list方法的典型用法代码示例。如果您正苦于以下问题:Java Registry.list方法的具体用法?Java Registry.list怎么用?Java Registry.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.registry.Registry
的用法示例。
在下文中一共展示了Registry.list方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkIfRegistryRunning
import java.rmi.registry.Registry; //导入方法依赖的package包/类
/**
* Helper method to determine if registry has started
*
* @param port The port number to check
* @param msTimeout The amount of milliseconds to spend checking
*/
public static boolean checkIfRegistryRunning(int port, int msTimeout) {
long stopTime = System.currentTimeMillis() + msTimeout;
do {
try {
Registry r = LocateRegistry.getRegistry(port);
String[] s = r.list();
// no exception. We're now happy that registry is running
return true;
} catch (RemoteException e) {
// problem - not ready ? Try again
try {
Thread.sleep(500);
} catch (InterruptedException ie) {
// not expected
}
}
} while (stopTime > System.currentTimeMillis());
return false;
}
示例2: checkIfRegistryRunning
import java.rmi.registry.Registry; //导入方法依赖的package包/类
/**
* Helper method to determine if registry has started
*
* @param port The port number to check
* @param msTimeout The amount of milliseconds to spend checking
*/
public static boolean checkIfRegistryRunning(int port, int msTimeout) {
final long POLLTIME_MS = 100L;
long stopTime = computeDeadline(System.currentTimeMillis(), msTimeout);
do {
try {
Registry r = LocateRegistry.getRegistry(port);
String[] s = r.list();
// no exception. We're now happy that registry is running
return true;
} catch (RemoteException e) {
// problem - not ready ? Try again
try {
Thread.sleep(POLLTIME_MS);
} catch (InterruptedException ie) {
// not expected
}
}
} while (System.currentTimeMillis() < stopTime);
return false;
}
示例3: vaciarRegistroRMI
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static boolean vaciarRegistroRMI (Registry regtr) {
if (regtr == null) return true;
// ItfUsoRecursoTrazas trazas = Directorio.getRecursoTrazas();
// NombresPredefinidos.REPOSITORIO_INTERFACES_OBJ = repositorioInterfaces;
try {
trazas.aceptaNuevaTraza(new InfoTraza ("AdaptadorRegRMI", "Vaciando registro RMI", NivelTraza.info));
String [] listaRemotos = regtr.list();
for (String obj : listaRemotos) regtr.unbind(obj);
return true;
} catch (Exception e) {
trazas.aceptaNuevaTraza(new InfoTraza("AdaptadorRegRMI", "Fallo al vaciar registro RMI", NivelTraza.error));
return false;
}
}
示例4: testConnect
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private static void testConnect(int port, int rmiPort) throws Exception {
dbg_print("RmiRegistry lookup...");
dbg_print("Using port: " + port);
dbg_print("Using rmi port: " + rmiPort);
Registry registry = LocateRegistry.getRegistry(port);
// "jmxrmi"
String[] relist = registry.list();
for (int i = 0; i < relist.length; ++i) {
dbg_print("Got registry: " + relist[i]);
}
String jmxUrlStr = (rmiPort != 0) ?
String.format(
"service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi",
rmiPort,
port) :
String.format(
"service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",
port);
JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
JMXConnector c = JMXConnectorFactory.connect(url, null);
MBeanServerConnection conn = c.getMBeanServerConnection();
ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
int count = listMBeans(conn,pattern,null);
if (count == 0)
throw new Exception("Expected at least one matching " +
"MBean for " + pattern);
}
示例5: doTestConnect
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private static void doTestConnect(int port, int rmiPort) throws Exception {
dbg_print("RmiRegistry lookup...");
dbg_print("Using port: " + port);
dbg_print("Using rmi port: " + rmiPort);
Registry registry = LocateRegistry.getRegistry(port);
// "jmxrmi"
String[] relist = registry.list();
for (int i = 0; i < relist.length; ++i) {
dbg_print("Got registry: " + relist[i]);
}
String jmxUrlStr = (rmiPort != 0) ?
String.format(
"service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi",
rmiPort,
port) :
String.format(
"service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",
port);
JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
JMXConnector c = JMXConnectorFactory.connect(url, null);
MBeanServerConnection conn = c.getMBeanServerConnection();
ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
int count = listMBeans(conn,pattern,null);
if (count == 0)
throw new Exception("Expected at least one matching " +
"MBean for " + pattern);
}
示例6: verifyNoRmiRegistryOnDefaultPort
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private void verifyNoRmiRegistryOnDefaultPort() throws Exception {
try {
Registry registry = LocateRegistry.getRegistry();
registry.list();
throw new Exception("There is already RMI registry on the default port: " + registry);
} catch (RemoteException e) {
// No RMI registry on default port is detected
}
}
示例7: getRegistry
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private Registry getRegistry() throws RemoteException {
Registry registry = LocateRegistry.getRegistry(this.registryPort);
try {
registry.list();
} catch (RemoteException e) {
registry = null;
}
if (registry == null) {
registry = LocateRegistry.createRegistry(this.registryPort);
}
return registry;
}
示例8: testRegistry
import java.rmi.registry.Registry; //导入方法依赖的package包/类
private void testRegistry(Registry registry) throws RemoteException {
registry.list();
}
示例9: main
import java.rmi.registry.Registry; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4486732\n");
Factory factoryImpl = new FactoryImpl();
Factory factoryStub =
(Factory) UnicastRemoteObject.exportObject(factoryImpl, 0);
for (int i = 0; i < SESSIONS; i++) {
Session session = factoryStub.getSession();
session.ping();
}
UnicastRemoteObject.unexportObject(factoryImpl, true);
Registry registryImpl = TestLibrary.createRegistryOnEphemeralPort();
int port = TestLibrary.getRegistryPort(registryImpl);
System.out.println("Registry listening on port " + port);
CSF csf = new CSF();
Reference<CSF> registryRef = new WeakReference<CSF>(csf);
Registry registryStub = LocateRegistry.getRegistry("", port, csf);
csf = null;
registryStub.list();
registryStub = null;
UnicastRemoteObject.unexportObject(registryImpl, true);
System.gc();
// allow connections to time out
Thread.sleep(3 * Long.getLong("sun.rmi.transport.connectionTimeout",
15000));
System.gc();
if (CSF.deserializedInstances.size() != SESSIONS) {
throw new Error("unexpected number of deserialized instances: " +
CSF.deserializedInstances.size());
}
int nonNullCount = 0;
for (Reference<CSF> ref : CSF.deserializedInstances) {
csf = ref.get();
if (csf != null) {
System.err.println("non-null deserialized instance: " + csf);
nonNullCount++;
}
}
if (nonNullCount > 0) {
throw new Error("TEST FAILED: " +
nonNullCount + " non-null deserialized instances");
}
csf = registryRef.get();
if (csf != null) {
System.err.println("non-null registry instance: " + csf);
throw new Error("TEST FAILED: non-null registry instance");
}
System.err.println("TEST PASSED");
}
示例10: testRegistry
import java.rmi.registry.Registry; //导入方法依赖的package包/类
/**
* Test the given RMI registry, calling some operation on it to
* check whether it is still active.
* <p>Default implementation calls {@code Registry.list()}.
* @param registry the RMI registry to test
* @throws RemoteException if thrown by registry methods
* @see java.rmi.registry.Registry#list()
*/
protected void testRegistry(Registry registry) throws RemoteException {
registry.list();
}