ehcache

net.sf.ehcache.distribution
Class ConfigurableRMIClientSocketFactory

java.lang.Object
  extended by net.sf.ehcache.distribution.ConfigurableRMIClientSocketFactory
All Implemented Interfaces:
Serializable, RMIClientSocketFactory

public final class ConfigurableRMIClientSocketFactory
extends Object
implements Serializable, RMIClientSocketFactory

Default socket timeouts are unlikely to be suitable for cache replication. Sockets should fail fast.

This class decorates the RMIClientSocketFactory so as to enable customisations to be placed on newly created sockets.

Version:
$Id: ConfigurableRMIClientSocketFactory.java 9255 2014-08-26 08:38:01Z sund $
Author:
Greg Luck
See Also:
Serialized Form

Constructor Summary
ConfigurableRMIClientSocketFactory(Integer socketTimeoutMillis)
          Construct a new socket factory with the given timeout.
 
Method Summary
 Socket createSocket(String host, int port)
          Create a client socket connected to the specified host and port.
 boolean equals(Object object)
          The standard hashCode method which is necessary for SocketFactory classes.
static RMISocketFactory getConfiguredRMISocketFactory()
          Return the JVM-level configured RMISocketFactory.
 int hashCode()
          Implements the Object hashCode method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurableRMIClientSocketFactory

public ConfigurableRMIClientSocketFactory(Integer socketTimeoutMillis)
Construct a new socket factory with the given timeout.

Parameters:
socketTimeoutMillis -
See Also:
Socket.setSoTimeout(int)
Method Detail

createSocket

public Socket createSocket(String host,
                           int port)
                    throws IOException
Create a client socket connected to the specified host and port.

If necessary this implementation can be changed to specify the outbound address to use e.g. Socket socket = new Socket(host, port, localInterface , 0);

Specified by:
createSocket in interface RMIClientSocketFactory
Parameters:
host - the host name
port - the port number
Returns:
a socket connected to the specified host and port.
Throws:
IOException - if an I/O error occurs during socket creation
Since:
1.2

hashCode

public int hashCode()
Implements the Object hashCode method.

Overrides:
hashCode in class Object
Returns:
a hash based on socket options

equals

public boolean equals(Object object)
The standard hashCode method which is necessary for SocketFactory classes. Omitting this method causes RMI to quickly error out with "too many open files" errors.

Overrides:
equals in class Object
Parameters:
object - the comparison object
Returns:
equal if the classes are the same and the socket options are the name.

getConfiguredRMISocketFactory

public static RMISocketFactory getConfiguredRMISocketFactory()
Return the JVM-level configured RMISocketFactory.

If a global socket factory has been set via the RMISocketFactory.setSocketFactory(RMISocketFactory) method then that factory will be returned. Otherwise the default socket factory as returned by RMISocketFactory.getDefaultSocketFactory() is used instead.

Returns:
the configured @{code RMISocketFactory

ehcache

Copyright 2001-2016, Terracotta, Inc.