JTR 5.0 API Documentation

jtr.remote.utils
Class RmiUtil

java.lang.Object
  extended by jtr.remote.utils.RmiUtil

public class RmiUtil
extends java.lang.Object

This class provides utility methods for managing the registry service and for registering new services to it.

Since:
4.0
Version:
5.0
Author:
frusso

Constructor Summary
RmiUtil()
           
 
Method Summary
static java.rmi.registry.Registry launchRegistry(java.lang.String host, int port)
          Launches the registry on the given host and on the given port.
Note: the registry can only be started on the localhost.
static void logRegistryContent(java.rmi.registry.Registry r)
          This method logs the content of the registry.
static java.rmi.Remote lookupServer(NodeInfo jtrNode)
          Utility method for performing server look-up.
static java.rmi.Remote registerService(java.rmi.registry.Registry r, java.lang.Class<? extends java.rmi.Remote> service, java.lang.String serviceName)
          This method looks-up/registers a service on the registry.
static void setSystemProperties()
          This method sets all the properties required by the JTR distributed-runtime to work propertly.
In more detail this methods looks for the java.rmi.server.hostname and, if not defined, it is set to be equal to the value of the jtr.remote.test.host property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RmiUtil

public RmiUtil()
Method Detail

launchRegistry

public static final java.rmi.registry.Registry launchRegistry(java.lang.String host,
                                                              int port)
Launches the registry on the given host and on the given port.
Note: the registry can only be started on the localhost. Should a different host be specified, this method will try to connect to the remote registry.

Parameters:
host - The host name the registry is running on
port - The port the registry is attached to
Returns:
The lauched/discovered registry
Throws:
RmiUtilException - Thrown if unable to lauch the registry

registerService

public static final java.rmi.Remote registerService(java.rmi.registry.Registry r,
                                                    java.lang.Class<? extends java.rmi.Remote> service,
                                                    java.lang.String serviceName)
This method looks-up/registers a service on the registry. Firstly it tries to lookup the service; should it fail, it tries to bind it.

Parameters:
r - The registry
service - The service definition
serviceName - The name under which the service must be registered
Returns:
Remote The service instance, or null in case of error

lookupServer

public static java.rmi.Remote lookupServer(NodeInfo jtrNode)
                                    throws LocatorException
Utility method for performing server look-up.

Parameters:
jtrNode -
Returns:
The remote reference to the looked-up object
Throws:
LocatorException

logRegistryContent

public static final void logRegistryContent(java.rmi.registry.Registry r)
This method logs the content of the registry.

Parameters:
r - The registry

setSystemProperties

public static final void setSystemProperties()
This method sets all the properties required by the JTR distributed-runtime to work propertly.
In more detail this methods looks for the java.rmi.server.hostname and, if not defined, it is set to be equal to the value of the jtr.remote.test.host property.


The JTR Project is licensed under GPL version 2