springs.util
Class RMIUtilities

java.lang.Object
  |
  +--springs.util.RMIUtilities
All Implemented Interfaces:
ConfigurationParameters, Debug

public class RMIUtilities
extends java.lang.Object
implements ConfigurationParameters

Utilities for RMI.

Author:
Sergio Ilarri Artigas

Field Summary
 
Fields inherited from interface springs.common.ConfigurationParameters
_persistence, ACTIVATE_AUTOMATIC_REFERENCES_UPDATES, ACTIVATE_NAMING_SERVICE, AGENT_REFERENCES_UPDATER_NAME, BACKLOG, BLOCK_UNTIL_REFERENCE_UPDATED_IF_NEEDED, COLLECT_LOGS_CALLS, CONTEXT_MANAGER_NAME, CONTEXT_WATCHING_PERIOD, CRASH_WHEN_NOT_ENOUGH_MEMORY, CREATE_AGENTS_IN_BACKGROUND, DEFAULT_PORT_NUMBER_FOR_CONTEXTS, DELAY_DEPARTURES_IF_NEEDED, DISABLE_LOGGER, EXPORT_RETRIAL, FORCE_REMOVALS, HYBRID_STRATEGY_PROXY_UPDATE, INITIAL_SEPARATOR_URL, LAZY_UPDATE_AGENT_OBJECT, LEASE_VALUE, MAX_MILLIS_TO_WAIT_FOR_ARU, MAX_MILLIS_TO_WAIT_FOR_UPDATE_REFERENCE, MAX_TRIES_ASSIGNING_THREAD_TO_AGENT, MAXIMUM_NUMBER_OF_CONSECUTIVE_FAILED_PINGS, MILLIS_TO_KEEP_MARKED_TO_REMOVE_REFERENCES, MILLIS_TO_KEEP_UNUSED_LOCAL_REFERENCES, MILLIS_TO_WAIT_FOR_CLASS_SERVER_READY, MILLIS_TO_WAIT_FOR_RMI_REGISTRY_CREATION, MINIMUM_MILLIS_STAY_AT_CONTEXT, NUM_STAYS_TO_COMPUTE_AVERAGE_STAY, PERIOD_LARC, REBIND_RETRIAL, REGION_NAME_SERVER_NAME, RETRYING_STRATEGY_FOR_AGENT_SEARCHING, RETRYING_STRATEGY_FOR_CREATIONS, RETRYING_STRATEGY_FOR_INVOKATIONS, RETRYING_STRATEGY_FOR_REMOTE_REFERENCE_UPDATING, RETURN_CALL_RESULTS_WITH_STATISTICS, RMI_PROTOCOL, SECURITY_POLICY, TIME_BETWEEN_TRIES_ASSIGNING_THREAD_TO_AGENT, TIMEOUT_CONNECTION_RMI, TIMEOUT_RMI, TRACE_RMI_SERVERS, TRACKING_FACTOR, UPDATE_REFERENCES_IN_BACKGROUND, UPDATE_REFERENCES_WITH_AUXILIARY_THREAD, USE_CACHE_OF_CLASSES, USE_SOCKETS_COUNTING_BYTES, USE_SPECIFIC_SOCKET_FACTORY, WAIT_UNTIL_REFERENCES_UPDATED, WRITE_CONTEXT_LOGS_IN_STDOUT
 
Fields inherited from interface springs.common.Debug
DEBUG_ACCESS_SERVICE, DEBUG_BASIC, DEBUG_CLASS_LOADING, DEBUG_CONTEXT_MANAGER, DEBUG_CONTEXT_STATUS_WHEN_MEMORY_ERROR, DEBUG_CREATION, DEBUG_DELETING, DEBUG_NAMING_SERVICE, DEBUG_PROBLEMS_WITH_RMI_CLASS_LOADING, DEBUG_REFERENCE_UPDATER, DEBUG_REMOVAL, DEBUG_RMI, DEBUG_RMI_FAILURES, DEBUG_RNS, DEBUG_SEARCHING, DEBUG_SENDING, DEBUG_TIMES, LOG_CONTEXT_INFO, PRINT_EXCEPTION_FAILED_REMOTE_CALLS, PRINT_FAILED_MOVEMENTS, PRINT_FAILED_REMOTE_CALLS, PRINT_FAILED_REMOTE_REFERENCE_UPDATING, PRINT_FAILED_SEARCHINGS, PRINT_RETRYING_TASK_FAILURES, PROXY_QUEUE
 
Constructor Summary
RMIUtilities()
           
 
Method Summary
static java.lang.String convert2LookupString(java.lang.String url, java.lang.String agentName)
          Converts into a lookup string.
static java.lang.String convertURL2RMIFormat(java.lang.String url)
          Converts an URL into the RMI format.
static java.lang.String getURL(java.lang.String host, int port)
          Gets an RMI URL.
static java.lang.Object lookup(java.lang.String url, java.lang.String objectName)
          Searches for an object.
static boolean ping(int port)
          Checks if there is an RMI registry in the given port.
static boolean ping(java.lang.String host, int port)
          Checks if there is an RMI registry in the given port and host.
static void printObjects(java.lang.String url)
          Prints the names of the objects registered in the given URL.
static void printObjects(java.lang.String host, int port)
          Prints the names of the objects registered in the given RMI server.
static void printObjectsLocalRegistry()
          Prints the names of the objects registered in the local RMI registry.
static void registerServer(java.lang.String name, java.rmi.Remote server, int port)
          Registers a server in the given port.
static void registerServer(java.lang.String name, java.rmi.Remote server, java.rmi.registry.Registry registry, int port)
          Registers a server in the given port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RMIUtilities

public RMIUtilities()
Method Detail

convertURL2RMIFormat

public static java.lang.String convertURL2RMIFormat(java.lang.String url)
Converts an URL into the RMI format.

Parameters:
url - the URL.
Returns:
the converted URL.
See Also:
String

convert2LookupString

public static java.lang.String convert2LookupString(java.lang.String url,
                                                    java.lang.String agentName)
Converts into a lookup string.

Parameters:
url - the URL.
agentName - the name of the agent.
Returns:
the converted URL.
See Also:
String

getURL

public static java.lang.String getURL(java.lang.String host,
                                      int port)
Gets an RMI URL.

Parameters:
host - the host name.
port - the port number.
Returns:
the RMI URL.
See Also:
String

lookup

public static java.lang.Object lookup(java.lang.String url,
                                      java.lang.String objectName)
                               throws CommunicationException
Searches for an object.

Parameters:
url - the URL of the object.
objectName - the name of the object.
Throws:
CommunicationException - if there is an error.
See Also:
Object, String, CommunicationException

printObjectsLocalRegistry

public static void printObjectsLocalRegistry()
Prints the names of the objects registered in the local RMI registry.


printObjects

public static void printObjects(java.lang.String host,
                                int port)
                         throws java.rmi.RemoteException,
                                java.net.MalformedURLException
Prints the names of the objects registered in the given RMI server.

Parameters:
host - the host name.
port - the port number.
Throws:
java.rmi.RemoteException - if the registry cannot be contacted.
java.net.MalformedURLException - if the URL is wrong.
See Also:
String, RemoteException, MalformedURLException

printObjects

public static void printObjects(java.lang.String url)
                         throws java.rmi.RemoteException,
                                java.net.MalformedURLException
Prints the names of the objects registered in the given URL.

Parameters:
url - the URL.
Throws:
java.rmi.RemoteException - if the registry cannot be contacted.
java.net.MalformedURLException - if the URL is wrong.
See Also:
String, RemoteException, MalformedURLException

ping

public static boolean ping(int port)
Checks if there is an RMI registry in the given port.

Parameters:
port - the port number.
Returns:
a boolean indicating if there is a registry there.

ping

public static boolean ping(java.lang.String host,
                           int port)
Checks if there is an RMI registry in the given port and host.

Parameters:
host - the host.
port - the port number.
Returns:
a boolean indicating if there is a registry there.
See Also:
String

registerServer

public static void registerServer(java.lang.String name,
                                  java.rmi.Remote server,
                                  int port)
                           throws java.rmi.RemoteException
Registers a server in the given port.

Parameters:
name - the name of the server.
server - the server.
port - the port.
Throws:
java.rmi.RemoteException - if the registry cannot be contacted.
See Also:
String, Remote, RemoteException

registerServer

public static void registerServer(java.lang.String name,
                                  java.rmi.Remote server,
                                  java.rmi.registry.Registry registry,
                                  int port)
                           throws java.rmi.RemoteException
Registers a server in the given port.

Parameters:
name - the name of the server.
server - the server.
port - the port.
registry - the registry.
java.rmi.RemoteException
See Also:
String, Remote, Registry