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

public class SocketClientInvoker
extends RemoteClientInvoker

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

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

Nested Class Summary
protected static class SocketClientInvoker.ClientSocket
           
 
Field Summary
protected  ServerAddress address
          connection information
protected static HashMap connectionPools
           
static long deserializeTime
           
protected  boolean enableTcpNoDelay
          If the TcpNoDelay option should be used on the socket.
static long getSocketTime
           
static String MAX_POOL_SIZE_FLAG
           
static int MAX_RETRIES
          Set number of retries in getSocket method
protected  int maxPoolSize
           
protected  int numberOfRetries
           
protected  LinkedList pool
          Pool for this invoker.
static long readTime
           
static long serializeTime
           
static int SO_TIMEOUT_DEFAULT
           
static String SO_TIMEOUT_FLAG
           
static boolean TCP_NODELAY_DEFAULT
           
static 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, localServerLocator, locator, log
 
Constructor Summary
SocketClientInvoker(InvokerLocator locator)
           
 
Method Summary
static void clearPool(ServerAddress 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 getConnection()
           
protected  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 getPooledConnection()
           
 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  Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller)
           
 
Methods inherited from class org.jboss.remoting.RemoteClientInvoker
connect, disconnect, getMarshaller, getUnMarshaller, invoke, isConnected, postProcess, preProcess, setMarshaller, setUnMarshaller
 
Methods inherited from class org.jboss.remoting.AbstractInvoker
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
getClientLocator, setClientLocator
 
Methods inherited from interface org.jboss.remoting.Invoker
getLocator
 

Field Detail

TCP_NODELAY_FLAG

public static final String TCP_NODELAY_FLAG
See Also:
Constant Field Values

MAX_POOL_SIZE_FLAG

public static final String MAX_POOL_SIZE_FLAG
See Also:
Constant Field Values

SO_TIMEOUT_FLAG

public static final String SO_TIMEOUT_FLAG
See Also:
Constant Field Values

SO_TIMEOUT_DEFAULT

public static final int SO_TIMEOUT_DEFAULT
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

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 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 static HashMap connectionPools

maxPoolSize

protected int maxPoolSize
Constructor Detail

SocketClientInvoker

public SocketClientInvoker(InvokerLocator locator)
                    throws IOException
Method Detail

setup

protected void setup()
              throws Exception
Throws:
Exception

finalize

protected void finalize()
                 throws 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:
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 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 Object transport(String sessionId,
                           Object invocation,
                           Map metadata,
                           Marshaller marshaller,
                           UnMarshaller unmarshaller)
                    throws IOException,
                           ConnectionFailedException,
                           ClassNotFoundException
Specified by:
transport in class RemoteClientInvoker
Parameters:
sessionId -
invocation -
marshaller -
Returns:
Throws:
IOException
ConnectionFailedException
ClassNotFoundException

clearPool

public static void clearPool(ServerAddress 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 getConnection()
                                                  throws Exception
Throws:
Exception

getPooledConnection

protected SocketClientInvoker.ClientSocket getPooledConnection()

getServerHostName

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

Throws:
Exception


Copyright © 2004 JBoss Inc. All Rights Reserved.