org.jboss.remoting.transport.rmi
Class RemotingRMIClientSocketFactory

java.lang.Object
  extended byorg.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory
All Implemented Interfaces:
java.rmi.server.RMIClientSocketFactory, java.io.Serializable

public class RemotingRMIClientSocketFactory
extends java.lang.Object
implements java.rmi.server.RMIClientSocketFactory, java.io.Serializable

RemotingRMIClientSocketFactory provides two services to RMIServerInvoker.

  1. It can be parameterized by a host name, allowing RMIServerInvoker to supply RMI with a factory which creates sockets connected to a specified host name.

  2. It can be parameterized by a SocketFactory allowing RMIServerInvoker to supply RMI with a factory facility which creates specialized sockets.

if the SocketFactory parameter is specified, then the RemotingRMIClientSocketFactory should be used with a matching instance of RemotingRMIServerSocketFactory with a compatible ServerSocketFactory.

If the SocketFactory parameter is not specified, an instance of java.net.Socket will be created by default.

Although there is no apparent need for the host name parameter, since the createSocket() method receives a host name, it seems that for a server object bound to localhost, the RMI runtime will pass to createSocket() one of the IP addresses for which the host is configured (other than 127.0.0.1), resulting in a failure to retrieve the object from the Registry. If a host name is passed to a RemotingRMIClientFactory constructor, it will override the host name passed to createSocket() In particular, parameterizing RemotingRMIClientSocketFactory with localhost will allow the retrieval of objects bound to localhost.

Version:
$Revision: 1.5 $

Copyright (c) 2005

Author:
Ron Sigal
See Also:
Serialized Form

Constructor Summary
RemotingRMIClientSocketFactory()
           
RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory)
           
RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory, java.lang.String hostName)
           
RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory, java.lang.String hostName, int timeout)
           
RemotingRMIClientSocketFactory(java.lang.String hostName, int timeout)
           
 
Method Summary
 java.net.Socket createSocket(java.lang.String host, int port)
          Creates a new socket.
 boolean equals(java.lang.Object o)
          Overrides equals() method provided by Object class.
 int hashCode()
          Overrides hashCode() method provided by the Object class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemotingRMIClientSocketFactory

public RemotingRMIClientSocketFactory()

RemotingRMIClientSocketFactory

public RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory)
Parameters:
socketFactory - the SocketFactory to be used to generate sockets

RemotingRMIClientSocketFactory

public RemotingRMIClientSocketFactory(java.lang.String hostName,
                                      int timeout)
Parameters:
hostName - name of host to which all generated sockets should be connected

RemotingRMIClientSocketFactory

public RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory,
                                      java.lang.String hostName,
                                      int timeout)

RemotingRMIClientSocketFactory

public RemotingRMIClientSocketFactory(javax.net.SocketFactory socketFactory,
                                      java.lang.String hostName)
Parameters:
socketFactory - the SocketFactory to be used to generate sockets
hostName - name of host to which all generated sockets should be connected
Method Detail

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port)
                             throws java.io.IOException
Creates a new socket. If a SocketFactory was passed to the constructor, it will be used. Otherwise, a java.net.Socket will be created by default.

Specified by:
createSocket in interface java.rmi.server.RMIClientSocketFactory
Parameters:
host - host to which socket should be connected
port - port to which socket should be connected
Returns:
new socket
Throws:
java.io.IOException - if there is a problem creating a socket

equals

public boolean equals(java.lang.Object o)
Overrides equals() method provided by Object class. It looks for equality of host name and socket factory parameters.

Parameters:
o - Object to which this is to be compared
Returns:
true if and only if o and this are equal

hashCode

public int hashCode()
Overrides hashCode() method provided by the Object class.

Returns:
a hashcode for this


Copyright ? 1998-2005 JBoss Inc . All Rights Reserved.