Author: asmuts
Date: Wed Mar 29 08:15:39 2006
New Revision: 389818
URL: http://svn.apache.org/viewcvs?rev=389818&view=rev
Log:
removed the possiblity of a null pointer when the listener id is not registered.
added a special socket factory with timeouts
added the ability to configure the rmi timeout.
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
URL:
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=389818&r1=389817&r2=389818&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
Wed Mar 29 08:15:39 2006
@@ -509,7 +509,7 @@
}
boolean fromCluster = false;
- if ( remoteTypeL.intValue() == IRemoteCacheAttributes.CLUSTER )
+ if ( remoteTypeL != null && remoteTypeL.intValue() ==
IRemoteCacheAttributes.CLUSTER )
{
fromCluster = true;
}
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
URL:
http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=389818&r1=389817&r2=389818&view=diff
==============================================================================
---
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
(original)
+++
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
Wed Mar 29 08:15:39 2006
@@ -18,9 +18,12 @@
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.ServerSocket;
+import java.net.Socket;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.registry.Registry;
+import java.rmi.server.RMISocketFactory;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -43,6 +46,8 @@
private static String serviceName;
+ private static int DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MS = 10000;
+
/** Constructor for the RemoteCacheServerFactory object. */
private RemoteCacheServerFactory()
{
@@ -89,6 +94,33 @@
if ( log.isInfoEnabled() )
{
log.info( "ConfigFileName = [" + propFile + "]" );
+ }
+
+ try
+ {
+ // TODO make configurable.
+ // use this socket factory to add a timeout.
+ RMISocketFactory.setSocketFactory( new RMISocketFactory()
+ {
+ public Socket createSocket( String host, int port )
+ throws IOException
+ {
+ Socket socket = new Socket( host, port );
+ socket.setSoTimeout(
DEFAULT_RMI_SOCKET_FACTORY_TIMEOUT_MS );
+ socket.setSoLinger( false, 0 );
+ return socket;
+ }
+
+ public ServerSocket createServerSocket( int port )
+ throws IOException
+ {
+ return new ServerSocket( port );
+ }
+ } );
+ }
+ catch ( Exception e )
+ {
+ log.error( "Problem setting custom RMI Socket Factory.", e );
}
// TODO: make automatic
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]