org.jboss.remoting.transport.socket
Class SocketClientInvoker

java.lang.Object
  extended byorg.jboss.remoting.AbstractInvoker (src) 
      extended byorg.jboss.remoting.RemoteClientInvoker (src) 
          extended byorg.jboss.remoting.transport.socket.SocketClientInvoker
All Implemented Interfaces:
ClientInvoker (src) , Invoker (src)

public class SocketClientInvoker
extends RemoteClientInvoker (src)

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


Nested Class Summary
protected static class SocketClientInvoker.ClientSocket (src)
           
 
Field Summary
protected  ServerAddress (src) address
          connection information
protected static 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
           
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 (src)
connected
 
Fields inherited from class org.jboss.remoting.AbstractInvoker (src)
classbyteloader, localServerLocator, locator, log
 
Constructor Summary
SocketClientInvoker(InvokerLocator (src)  locator)
           
 
Method Summary
static void clearPool(ServerAddress (src)  sa)
          Close all sockets in a specific pool.
static void clearPools()
          Close all sockets in all pools
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  SocketClientInvoker.ClientSocket (src) 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  SocketClientInvoker.ClientSocket (src) 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 (src)  marshaller, UnMarshaller (src)  unmarshaller)
           
 
Methods inherited from class org.jboss.remoting.RemoteClientInvoker (src)
connect, disconnect, getMarshaller, getUnMarshaller, invoke, isConnected, postProcess, preProcess, setMarshaller, setUnMarshaller
 
Methods inherited from class org.jboss.remoting.AbstractInvoker (src)
getClassLoader, getClientLocator, getLocator, setClassLoader, setClientLocator
 
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 (src)
getClientLocator, setClientLocator
 
Methods inherited from interface org.jboss.remoting.Invoker (src)
getLocator
 

Field Detail

TCP_NODELAY_FLAG

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

MAX_POOL_SIZE_FLAG

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

SO_TIMEOUT_FLAG

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

SO_TIMEOUT_DEFAULT

public static final int SO_TIMEOUT_DEFAULT
See Also:
Constant Field Values (src)

TCP_NODELAY_DEFAULT

public static final boolean TCP_NODELAY_DEFAULT
See Also:
Constant Field Values (src)

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

MAX_RETRIES

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

See Also:
Constant Field Values (src)

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 (src)  address
connection information


connectionPools

protected static java.util.HashMap connectionPools

maxPoolSize

protected int maxPoolSize
Constructor Detail

SocketClientInvoker

public SocketClientInvoker(InvokerLocator (src)  locator)
                    throws java.io.IOException
Method Detail

setup

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

finalize

protected void finalize()
                 throws java.lang.Throwable
Description copied from class: RemoteClientInvoker (src)
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 (src)
Throws:
java.lang.Throwable - the Exception raised by this method

handleConnect

protected void handleConnect()
                      throws ConnectionFailedException (src) 
Description copied from class: RemoteClientInvoker (src)
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 (src)
Throws:
ConnectionFailedException (src)

handleDisconnect

protected void handleDisconnect()
Description copied from class: RemoteClientInvoker (src)
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 (src)

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 (src)
Returns:

transport

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

clearPool

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


clearPools

public static 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 SocketClientInvoker.ClientSocket (src)  getConnection()
                                                  throws java.lang.Exception
Throws:
java.lang.Exception

getPooledConnection

protected SocketClientInvoker.ClientSocket (src)  getPooledConnection()

getServerHostName

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

Throws:
java.lang.Exception