java.rmi.server
Class RMISocketFactory

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.rmi.server.RMISocketFactory
All Implemented Interfaces:
RMIClientSocketFactory sample code for java.rmi.server.RMIClientSocketFactory definition code for java.rmi.server.RMIClientSocketFactory , RMIServerSocketFactory sample code for java.rmi.server.RMIServerSocketFactory definition code for java.rmi.server.RMIServerSocketFactory

public abstract class RMISocketFactory
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements RMIClientSocketFactory sample code for java.rmi.server.RMIClientSocketFactory definition code for java.rmi.server.RMIClientSocketFactory , RMIServerSocketFactory sample code for java.rmi.server.RMIServerSocketFactory definition code for java.rmi.server.RMIServerSocketFactory

An RMISocketFactory instance is used by the RMI runtime in order to obtain client and server sockets for RMI calls. An application may use the setSocketFactory method to request that the RMI runtime use its socket factory instance instead of the default implementation.

The default socket factory implementation used goes through a three-tiered approach to creating client sockets. First, a direct socket connection to the remote VM is attempted. If that fails (due to a firewall), the runtime uses HTTP with the explicit port number of the server. If the firewall does not allow this type of communication, then HTTP to a cgi-bin script on the server is used to POST the RMI call.

Since:
JDK1.1

Constructor Summary
RMISocketFactory sample code for java.rmi.server.RMISocketFactory.RMISocketFactory() definition code for java.rmi.server.RMISocketFactory.RMISocketFactory() ()
          Constructs an RMISocketFactory.
 
Method Summary
abstract  ServerSocket sample code for java.net.ServerSocket definition code for java.net.ServerSocket createServerSocket sample code for java.rmi.server.RMISocketFactory.createServerSocket(int) definition code for java.rmi.server.RMISocketFactory.createServerSocket(int) (int port)
          Create a server socket on the specified port (port 0 indicates an anonymous port).
abstract  Socket sample code for java.net.Socket definition code for java.net.Socket createSocket sample code for java.rmi.server.RMISocketFactory.createSocket(java.lang.String, int) definition code for java.rmi.server.RMISocketFactory.createSocket(java.lang.String, int) (String sample code for java.lang.String definition code for java.lang.String  host, int port)
          Creates a client socket connected to the specified host and port.
static RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory getDefaultSocketFactory sample code for java.rmi.server.RMISocketFactory.getDefaultSocketFactory() definition code for java.rmi.server.RMISocketFactory.getDefaultSocketFactory() ()
          Returns a reference to the default socket factory used by this RMI implementation.
static RMIFailureHandler sample code for java.rmi.server.RMIFailureHandler definition code for java.rmi.server.RMIFailureHandler getFailureHandler sample code for java.rmi.server.RMISocketFactory.getFailureHandler() definition code for java.rmi.server.RMISocketFactory.getFailureHandler() ()
          Returns the handler for socket creation failure set by the setFailureHandler method.
static RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory getSocketFactory sample code for java.rmi.server.RMISocketFactory.getSocketFactory() definition code for java.rmi.server.RMISocketFactory.getSocketFactory() ()
          Returns the socket factory set by the setSocketFactory method.
static void setFailureHandler sample code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler) definition code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler) (RMIFailureHandler sample code for java.rmi.server.RMIFailureHandler definition code for java.rmi.server.RMIFailureHandler  fh)
          Sets the failure handler to be called by the RMI runtime if server socket creation fails.
static void setSocketFactory sample code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory) definition code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory) (RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory  fac)
          Set the global socket factory from which RMI gets sockets (if the remote object is not associated with a specific client and/or server socket factory).
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

RMISocketFactory sample code for java.rmi.server.RMISocketFactory() definition code for java.rmi.server.RMISocketFactory()

public RMISocketFactory()
Constructs an RMISocketFactory.

Since:
JDK1.1
Method Detail

createSocket sample code for java.rmi.server.RMISocketFactory.createSocket(java.lang.String, int) definition code for java.rmi.server.RMISocketFactory.createSocket(java.lang.String, int)

public abstract Socket sample code for java.net.Socket definition code for java.net.Socket  createSocket(String sample code for java.lang.String definition code for java.lang.String  host,
                                    int port)
                             throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Creates a client socket connected to the specified host and port.

Specified by:
createSocket sample code for java.rmi.server.RMIClientSocketFactory.createSocket(java.lang.String, int) definition code for java.rmi.server.RMIClientSocketFactory.createSocket(java.lang.String, int) in interface RMIClientSocketFactory sample code for java.rmi.server.RMIClientSocketFactory definition code for java.rmi.server.RMIClientSocketFactory
Parameters:
host - the host name
port - the port number
Returns:
a socket connected to the specified host and port.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs during socket creation
Since:
JDK1.1

createServerSocket sample code for java.rmi.server.RMISocketFactory.createServerSocket(int) definition code for java.rmi.server.RMISocketFactory.createServerSocket(int)

public abstract ServerSocket sample code for java.net.ServerSocket definition code for java.net.ServerSocket  createServerSocket(int port)
                                         throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Create a server socket on the specified port (port 0 indicates an anonymous port).

Specified by:
createServerSocket sample code for java.rmi.server.RMIServerSocketFactory.createServerSocket(int) definition code for java.rmi.server.RMIServerSocketFactory.createServerSocket(int) in interface RMIServerSocketFactory sample code for java.rmi.server.RMIServerSocketFactory definition code for java.rmi.server.RMIServerSocketFactory
Parameters:
port - the port number
Returns:
the server socket on the specified port
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs during server socket creation
Since:
JDK1.1

setSocketFactory sample code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory) definition code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory)

public static void setSocketFactory(RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory  fac)
                             throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Set the global socket factory from which RMI gets sockets (if the remote object is not associated with a specific client and/or server socket factory). The RMI socket factory can only be set once. Note: The RMISocketFactory may only be set if the current security manager allows setting a socket factory; if disallowed, a SecurityException will be thrown.

Parameters:
fac - the socket factory
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if the RMI socket factory is already set
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkSetFactory method doesn't allow the operation.
Since:
JDK1.1
See Also:
getSocketFactory() sample code for java.rmi.server.RMISocketFactory.getSocketFactory() definition code for java.rmi.server.RMISocketFactory.getSocketFactory() , SecurityManager.checkSetFactory() sample code for java.lang.SecurityManager.checkSetFactory() definition code for java.lang.SecurityManager.checkSetFactory()

getSocketFactory sample code for java.rmi.server.RMISocketFactory.getSocketFactory() definition code for java.rmi.server.RMISocketFactory.getSocketFactory()

public static RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory  getSocketFactory()
Returns the socket factory set by the setSocketFactory method. Returns null if no socket factory has been set.

Returns:
the socket factory
Since:
JDK1.1
See Also:
setSocketFactory(RMISocketFactory) sample code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory) definition code for java.rmi.server.RMISocketFactory.setSocketFactory(java.rmi.server.RMISocketFactory)

getDefaultSocketFactory sample code for java.rmi.server.RMISocketFactory.getDefaultSocketFactory() definition code for java.rmi.server.RMISocketFactory.getDefaultSocketFactory()

public static RMISocketFactory sample code for java.rmi.server.RMISocketFactory definition code for java.rmi.server.RMISocketFactory  getDefaultSocketFactory()
Returns a reference to the default socket factory used by this RMI implementation. This will be the factory used by the RMI runtime when getSocketFactory returns null.

Returns:
the default RMI socket factory
Since:
JDK1.1

setFailureHandler sample code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler) definition code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler)

public static void setFailureHandler(RMIFailureHandler sample code for java.rmi.server.RMIFailureHandler definition code for java.rmi.server.RMIFailureHandler  fh)
Sets the failure handler to be called by the RMI runtime if server socket creation fails. By default, if no failure handler is installed and server socket creation fails, the RMI runtime does attempt to recreate the server socket.

If there is a security manager, this method first calls the security manager's checkSetFactory method to ensure the operation is allowed. This could result in a SecurityException.

Parameters:
fh - the failure handler
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if a security manager exists and its checkSetFactory method doesn't allow the operation.
Since:
JDK1.1
See Also:
getFailureHandler() sample code for java.rmi.server.RMISocketFactory.getFailureHandler() definition code for java.rmi.server.RMISocketFactory.getFailureHandler() , RMIFailureHandler.failure(Exception) sample code for java.rmi.server.RMIFailureHandler.failure(java.lang.Exception) definition code for java.rmi.server.RMIFailureHandler.failure(java.lang.Exception)

getFailureHandler sample code for java.rmi.server.RMISocketFactory.getFailureHandler() definition code for java.rmi.server.RMISocketFactory.getFailureHandler()

public static RMIFailureHandler sample code for java.rmi.server.RMIFailureHandler definition code for java.rmi.server.RMIFailureHandler  getFailureHandler()
Returns the handler for socket creation failure set by the setFailureHandler method.

Returns:
the failure handler
Since:
JDK1.1
See Also:
setFailureHandler(RMIFailureHandler) sample code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler) definition code for java.rmi.server.RMISocketFactory.setFailureHandler(java.rmi.server.RMIFailureHandler)