org.jboss.remoting.transport.socket
Class SocketClientInvoker

java.lang.Object
  extended byorg.jboss.remoting.AbstractInvoker
      extended byorg.jboss.remoting.RemoteClientInvoker
          extended byorg.jboss.remoting.transport.socket.SocketClientInvoker
All Implemented Interfaces:
ClientInvoker, Invoker
Direct Known Subclasses:
MultiplexClientInvoker, SSLSocketClientInvoker

public class SocketClientInvoker
extends RemoteClientInvoker

SocketClientInvoker uses Sockets to remotely connect to the a remote ServerInvoker, which must be a SocketServerInvoker.

Version:
$Revision: 1.30.2.1 $
Author:
Jeff Haynie, Tom Elrod

Field Summary
protected  ServerAddress address
          connection information
static java.lang.String CLIENT_SOCKET_CLASS_FLAG
           
protected  java.lang.String clientSocketClassName
           
protected  java.util.HashMap connectionPools
           
static long deserializeTime
           
protected  boolean enableTcpNoDelay
          If the TcpNoDelay option should be used on the socket.
static long getSocketTime
           
static java.lang.String MAX_POOL_SIZE_FLAG
           
static int MAX_RETRIES
          Set number of retries in getSocket method
protected  int maxPoolSize
           
protected  int numberOfRetries
           
protected  java.util.LinkedList pool
          Pool for this invoker.
static long readTime
           
static long serializeTime
           
static int SO_TIMEOUT_DEFAULT
          Default value for socket timeout is 30 minutes.
static java.lang.String SO_TIMEOUT_FLAG
           
static boolean TCP_NODELAY_DEFAULT
           
static java.lang.String TCP_NODELAY_FLAG
           
protected  int timeout
           
static long usedPooled
           
static long writeTime
           
 
Fields inherited from class org.jboss.remoting.RemoteClientInvoker
connected
 
Fields inherited from class org.jboss.remoting.AbstractInvoker
classbyteloader, configuration, localServerLocators, locator, log, serializationType
 
Constructor Summary
SocketClientInvoker(InvokerLocator locator)
           
SocketClientInvoker(InvokerLocator locator, java.util.Map configuration)
           
 
Method Summary
 void clearPool(ServerAddress sa)
          Close all sockets in a specific pool.
 void clearPools()
          Close all sockets in all pools
protected  void configureParameters()
           
protected  SocketWrapper createClientSocket(java.net.Socket socket, int timeout, java.util.Map metadata)
           
protected  java.net.Socket createSocket(java.lang.String address, int port)
           
protected  void finalize()
          Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
protected  SocketWrapper getConnection()
           
protected  java.lang.String getDefaultDataType()
          Each implementation of the remote client invoker should have a default data type that is uses in the case it is not specified in the invoker locator uri.
 int getNumberOfRetries()
           
protected  SocketWrapper getPooledConnection()
           
 java.lang.String getServerHostName()
          The name of of the server.
protected  void handleConnect()
          subclasses must implement this method to provide a hook to connect to the remote server, if this applies to the specific transport.
protected  void handleDisconnect()
          subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies to the specific transport.
protected  void initPool()
           
 void setNumberOfRetries(int numberOfRetries)
          Sets the number of retries to get a socket connection.
protected  void setup()
           
protected  java.lang.Object transport(java.lang.String sessionId, java.lang.Object invocation, java.util.Map metadata, Marshaller marshaller, UnMarshaller unmarshaller)
           
 
Methods inherited from class org.jboss.remoting.RemoteClientInvoker
connect, createSocketFactory, disconnect, getMarshaller, getSocketFactory, getUnMarshaller, invoke, isConnected, postProcess, preProcess, setMarshaller, setUnMarshaller
 
Methods inherited from class org.jboss.remoting.AbstractInvoker
addClientLocator, getClassLoader, getClientLocator, getLocator, getSerializationType, setClassLoader, setSerializationType
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.transport.ClientInvoker
addClientLocator, getClientLocator
 
Methods inherited from interface org.jboss.remoting.Invoker
getLocator
 

Field Detail

TCP_NODELAY_FLAG

public static final java.lang.String TCP_NODELAY_FLAG
See Also:
Constant Field Values

MAX_POOL_SIZE_FLAG

public static final java.lang.String MAX_POOL_SIZE_FLAG
See Also:
Constant Field Values

SO_TIMEOUT_FLAG

public static final java.lang.String SO_TIMEOUT_FLAG
See Also:
Constant Field Values

CLIENT_SOCKET_CLASS_FLAG

public static final java.lang.String CLIENT_SOCKET_CLASS_FLAG
See Also:
Constant Field Values

SO_TIMEOUT_DEFAULT

public static final int SO_TIMEOUT_DEFAULT
Default value for socket timeout is 30 minutes.

See Also:
Constant Field Values

TCP_NODELAY_DEFAULT

public static final boolean TCP_NODELAY_DEFAULT
See Also:
Constant Field Values

getSocketTime

public static long getSocketTime

readTime

public static long readTime

writeTime

public static long writeTime

serializeTime

public static long serializeTime

deserializeTime

public static long deserializeTime

enableTcpNoDelay

protected boolean enableTcpNoDelay
If the TcpNoDelay option should be used on the socket.


timeout

protected int timeout

clientSocketClassName

protected java.lang.String clientSocketClassName

MAX_RETRIES

public static final int MAX_RETRIES
Set number of retries in getSocket method

See Also:
Constant Field Values

usedPooled

public static long usedPooled

numberOfRetries

protected int numberOfRetries

pool

protected java.util.LinkedList pool
Pool for this invoker. This is shared between all instances of proxies attached to a specific invoker


address

protected ServerAddress address
connection information


connectionPools

protected java.util.HashMap connectionPools

maxPoolSize

protected int maxPoolSize
Constructor Detail

SocketClientInvoker

public SocketClientInvoker(InvokerLocator locator)
                    throws java.io.IOException

SocketClientInvoker

public SocketClientInvoker(InvokerLocator locator,
                           java.util.Map configuration)
                    throws java.io.IOException
Method Detail

setup

protected void setup()
              throws java.lang.Exception
Throws:
java.lang.Exception

configureParameters

protected void configureParameters()

finalize

protected void finalize()
                 throws java.lang.Throwable
Description copied from class: RemoteClientInvoker
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will transport the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Overrides:
finalize in class RemoteClientInvoker
Throws:
java.lang.Throwable - the Exception raised by this method

handleConnect

protected void handleConnect()
                      throws ConnectionFailedException
Description copied from class: RemoteClientInvoker
subclasses must implement this method to provide a hook to connect to the remote server, if this applies to the specific transport. However, in some transport implementations, this may not make must difference since the connection is not persistent among invocations, such as SOAP. In these cases, the method should silently return without any processing.

Specified by:
handleConnect in class RemoteClientInvoker
Throws:
ConnectionFailedException

handleDisconnect

protected void handleDisconnect()
Description copied from class: RemoteClientInvoker
subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies to the specific transport. However, in some transport implementations, this may not make must difference since the connection is not persistent among invocations, such as SOAP. In these cases, the method should silently return without any processing.

Specified by:
handleDisconnect in class RemoteClientInvoker

getDefaultDataType

protected java.lang.String getDefaultDataType()
Each implementation of the remote client invoker should have a default data type that is uses in the case it is not specified in the invoker locator uri.

Specified by:
getDefaultDataType in class RemoteClientInvoker
Returns:

transport

protected java.lang.Object transport(java.lang.String sessionId,
                                     java.lang.Object invocation,
                                     java.util.Map metadata,
                                     Marshaller marshaller,
                                     UnMarshaller unmarshaller)
                              throws java.io.IOException,
                                     ConnectionFailedException,
                                     java.lang.ClassNotFoundException
Specified by:
transport in class RemoteClientInvoker
Parameters:
sessionId -
invocation -
marshaller -
Returns:
Throws:
java.io.IOException
ConnectionFailedException
java.lang.ClassNotFoundException

clearPool

public void clearPool(ServerAddress sa)
Close all sockets in a specific pool.


clearPools

public void clearPools()
Close all sockets in all pools


initPool

protected void initPool()

setNumberOfRetries

public void setNumberOfRetries(int numberOfRetries)
Sets the number of retries to get a socket connection.

Parameters:
numberOfRetries - Must be a number greater than 0

getNumberOfRetries

public int getNumberOfRetries()

getConnection

protected SocketWrapper getConnection()
                               throws java.lang.Exception
Throws:
java.lang.Exception

createClientSocket

protected SocketWrapper createClientSocket(java.net.Socket socket,
                                           int timeout,
                                           java.util.Map metadata)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

createSocket

protected java.net.Socket createSocket(java.lang.String address,
                                       int port)
                                throws java.io.IOException
Throws:
java.io.IOException

getPooledConnection

protected SocketWrapper getPooledConnection()

getServerHostName

public java.lang.String getServerHostName()
                                   throws java.lang.Exception
The name of of the server.

Throws:
java.lang.Exception


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