org.jboss.remoting.transport.socket
Class SocketServerInvoker

java.lang.Object
  extended by org.jboss.remoting.AbstractInvoker
      extended by org.jboss.remoting.ServerInvoker
          extended by org.jboss.remoting.transport.socket.SocketServerInvoker
All Implemented Interfaces:
Invoker, ServerInvokerMBean, SocketServerInvokerMBean
Direct Known Subclasses:
BisocketServerInvoker, MultiplexServerInvoker, SSLSocketServerInvoker

public class SocketServerInvoker
extends ServerInvoker
implements SocketServerInvokerMBean

SocketServerInvoker is the server-side of a SOCKET based transport

Version:
$Revision: 5020 $
Author:
Jeff Haynie, Tom Elrod, Ovidiu Feodorov

Nested Class Summary
 class SocketServerInvoker.AcceptThread
           
 class SocketServerInvoker.IdleTimerTask
          The IdleTimerTask is used to periodically check the server threads to see if any have been idle for a specified amount of time, and if so, release those threads and their connections and clear from the server thread pool.
 class SocketServerInvoker.ServerSocketRefresh
          this thread checks if a new ServerSocketFactory was set,
if so initializes a serversocket refresh
 
Nested classes/interfaces inherited from class org.jboss.remoting.ServerInvoker
ServerInvoker.InvalidStateException
 
Nested classes/interfaces inherited from class org.jboss.remoting.AbstractInvoker
AbstractInvoker.CallbackLocatorHolder
 
Field Summary
protected  SocketServerInvoker.AcceptThread[] acceptThreads
           
protected  int backlog
           
static java.lang.String CHECK_CONNECTION_KEY
          Key for indicating if socket invoker should continue to keep socket connection between client and server open after invocations by sending a ping on the connection before being re-used.
protected  LRUPool clientpool
           
protected  int idleTimeout
           
protected  SocketServerInvoker.IdleTimerTask idleTimerTask
           
protected  boolean keepAlive
          More socket configuration parameters.
protected  boolean keepAliveSet
           
protected static int MAX_POOL_SIZE_DEFAULT
           
protected  int maxPoolSize
           
protected  boolean newServerSocketFactory
           
protected  int numAcceptThreads
           
protected  boolean oOBInline
           
protected  boolean oOBInlineSet
           
protected  java.util.Properties props
           
protected  int receiveBufferSize
           
protected  SocketServerInvoker.ServerSocketRefresh refreshThread
           
protected  boolean reuseAddress
           
protected  boolean running
           
protected  int sendBufferSize
           
static java.lang.String SERVER_SOCKET_CLASS_FLAG
          Specifies the fully qualified class name for the custom SocketWrapper implementation to use on the server.
protected  java.lang.String serverSocketClass
           
protected  java.lang.Object serverSocketFactoryLock
           
protected  java.util.List serverSockets
           
protected  boolean soLinger
           
protected  int soLingerDuration
           
protected  boolean soLingerSet
           
protected  java.util.LinkedList threadpool
           
protected  int trafficClass
           
 
Fields inherited from class org.jboss.remoting.ServerInvoker
BLOCKING, BLOCKING_MODE, BLOCKING_TIMEOUT, callbackHandlers, CLIENT_CONNECT_ADDRESS_KEY, CLIENT_CONNECT_PORT_KEY, CLIENT_LEASE_PERIOD, clientCallbackListener, connectHomes, CONNECTION_LISTENER, connectionNotifier, DEFAULT_BLOCKING_TIMEOUT, DEFAULT_CLIENT_LEASE_PERIOD, DEFAULT_TIMEOUT_PERIOD, ECHO, handlers, homes, INVOKER_SESSION_ID, MAX_NUM_ONEWAY_THREADS, MAX_NUM_ONEWAY_THREADS_KEY, MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, NONBLOCKING, ONEWAY_THREAD_POOL_CLASS_KEY, REGISTER_CALLBACK_LISTENER, registerCallbackListeners, SERVER_BIND_ADDRESS_KEY, SERVER_BIND_PORT_KEY, SERVER_SOCKET_FACTORY, serverSocketFactory, singleCallbackContainer, singleHandler, started, TIMEOUT
 
Fields inherited from class org.jboss.remoting.AbstractInvoker
classbyteloader, configuration, localServerLocators, locator, serializationType, socketFactory, socketFactoryCreatedFromSSLParameters, version
 
Constructor Summary
SocketServerInvoker(InvokerLocator locator)
           
SocketServerInvoker(InvokerLocator locator, java.util.Map configuration)
           
 
Method Summary
protected  void cleanup()
           
protected  void configureServerSocket(java.net.ServerSocket ss)
           
protected  void configureSocket(java.net.Socket s)
           
protected  java.net.ServerSocket createServerSocket(int serverBindPort, int backlog, java.net.InetAddress bindAddress)
           
protected  void createServerSockets()
           
 void destroy()
          Destory the invoker permanently.
protected  void finalize()
           
 int getBacklog()
           
 int getCurrentClientPoolSize()
           
 int getCurrentThreadPoolSize()
           
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 getIdleTimeout()
           
 int getMaxPoolSize()
          Setter for max pool size.
 int getNumAcceptThreads()
          Getter for property numAcceptThreads
 int getReceiveBufferSize()
           
 boolean getReuseAddress()
          Indicates if SO_REUSEADDR is enabled on server sockets Default is true.
 int getSendBufferSize()
           
 int getSoLingerDuration()
           
protected  java.lang.String getThreadName(int i)
           
 int getTrafficClass()
           
 boolean isKeepAlive()
           
 boolean isOOBInline()
           
 boolean isSoLinger()
           
 boolean isTransportBiDirectional()
          returns true if the transport is bi-directional in nature, for example, SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall for example).
protected  void processInvocation(java.net.Socket socket)
          The acceptor thread should spend as little time as possbile doing any kind of operation, and under no circumstances should perform IO on the new socket, which can potentially block and lock up the server.
protected  void refreshServerSocket()
          refreshes the serverSocket by closing old one and creating a new ServerSocket from new ServerSocketFactory
 void setBacklog(int backlog)
           
 void setIdleTimeout(int idleTimeout)
          Sets the timeout for idle threads to be removed from pool.
 void setKeepAlive(boolean keepAlive)
           
 void setMaxPoolSize(int maxPoolSize)
          The number of server threads for processing client.
 void setNewServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
          after a truststore update use this to set a new ServerSocketFactory to the invoker
then a new ServerSocket is created that accepts the new connections
 void setNumAcceptThreads(int size)
          Setter for property numAcceptThreads
 void setOOBInline(boolean inline)
           
 void setReceiveBufferSize(int receiveBufferSize)
           
 void setReuseAddress(boolean reuse)
          Sets if SO_REUSEADDR is enabled on server sockets.
 void setSendBufferSize(int sendBufferSize)
           
 void setSoLinger(boolean soLinger)
           
 void setSoLingerDuration(int soLingerDuration)
           
 void setTrafficClass(int trafficClass)
           
protected  void setup()
           
 void start()
          Starts the invoker.
 void stop()
          Stops the invoker.
 java.lang.String toString()
           
 
Methods inherited from class org.jboss.remoting.ServerInvoker
addConnectionListener, addInvocationHandler, assignPort, assignPorts, create, createHomeCollection, createServerSocketFactory, findInvocationHandler, getClientConnectAddress, getClientConnectPort, getConfiguration, getConnectHomes, getDataType, getDefaultServerSocketFactory, getHomes, getInvocationHandler, getInvocationHandlers, getLease, getLeasePeriod, getMaxNumberOfOnewayThreads, getMBeanObjectName, getMBeanServer, getOnewayThreadPool, getServerBindAddress, getServerBindPort, getServerSocketFactory, getSupportedSubsystems, getTimeout, handleInternalInvocation, hasInvocationHandler, invoke, invoke, isLeaseActivated, isRegisterCallbackListeners, isStarted, justNeedsSSLClientMode, postProcess, preProcess, removeCallbackHandler, removeCallbackListener, removeConnectionListener, removeInvocationHandler, setClientConnectAddress, setClientConnectPort, setConfiguration, setConnectHomes, setConnectionListener, setHomes, setLeasePeriod, setMaxNumberOfOnewayThreads, setMBeanServer, setOnewayThreadPool, setRegisterCallbackListeners, setServerSocketFactory, setTimeout, setupHomes, shutdownCallbackHandler, wrapServerSocketFactory
 
Methods inherited from class org.jboss.remoting.AbstractInvoker
addClientLocator, createSocketFactory, getClassLoader, getClientLocator, getClientLocators, getLocator, getSerializationType, getSocketFactory, getVersion, isCompleteSocketFactory, isSocketFactoryCreatedFromSSLParameters, needsCustomSSLConfiguration, setClassLoader, setSerializationType, setSocketFactory, setVersion, wrapSocketFactory
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.transport.socket.SocketServerInvokerMBean
getServerBindPort
 
Methods inherited from interface org.jboss.remoting.ServerInvokerMBean
create, getClientConnectAddress, getClientConnectPort, getConfiguration, getDataType, getServerBindAddress, getTimeout, isStarted, setClientConnectAddress, setClientConnectPort, setConfiguration, setTimeout
 

Field Detail

props

protected java.util.Properties props

MAX_POOL_SIZE_DEFAULT

protected static int MAX_POOL_SIZE_DEFAULT

CHECK_CONNECTION_KEY

public static final java.lang.String CHECK_CONNECTION_KEY
Key for indicating if socket invoker should continue to keep socket connection between client and server open after invocations by sending a ping on the connection before being re-used. The default for this is false.

See Also:
Constant Field Values

SERVER_SOCKET_CLASS_FLAG

public static final java.lang.String SERVER_SOCKET_CLASS_FLAG
Specifies the fully qualified class name for the custom SocketWrapper implementation to use on the server.

See Also:
Constant Field Values

serverSocketClass

protected java.lang.String serverSocketClass

serverSockets

protected java.util.List serverSockets

running

protected boolean running

backlog

protected int backlog

acceptThreads

protected SocketServerInvoker.AcceptThread[] acceptThreads

numAcceptThreads

protected int numAcceptThreads

maxPoolSize

protected int maxPoolSize

clientpool

protected LRUPool clientpool

threadpool

protected java.util.LinkedList threadpool

refreshThread

protected SocketServerInvoker.ServerSocketRefresh refreshThread

newServerSocketFactory

protected boolean newServerSocketFactory

serverSocketFactoryLock

protected java.lang.Object serverSocketFactoryLock

reuseAddress

protected boolean reuseAddress

receiveBufferSize

protected int receiveBufferSize

keepAlive

protected boolean keepAlive
More socket configuration parameters.


keepAliveSet

protected boolean keepAliveSet

oOBInline

protected boolean oOBInline

oOBInlineSet

protected boolean oOBInlineSet

sendBufferSize

protected int sendBufferSize

soLinger

protected boolean soLinger

soLingerSet

protected boolean soLingerSet

soLingerDuration

protected int soLingerDuration

trafficClass

protected int trafficClass

idleTimeout

protected int idleTimeout

idleTimerTask

protected SocketServerInvoker.IdleTimerTask idleTimerTask
Constructor Detail

SocketServerInvoker

public SocketServerInvoker(InvokerLocator locator)

SocketServerInvoker

public SocketServerInvoker(InvokerLocator locator,
                           java.util.Map configuration)
Method Detail

setNewServerSocketFactory

public void setNewServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
after a truststore update use this to set a new ServerSocketFactory to the invoker
then a new ServerSocket is created that accepts the new connections

Parameters:
serverSocketFactory -

refreshServerSocket

protected void refreshServerSocket()
                            throws java.io.IOException
refreshes the serverSocket by closing old one and creating a new ServerSocket from new ServerSocketFactory

Throws:
java.io.IOException

setup

protected void setup()
              throws java.lang.Exception
Overrides:
setup in class ServerInvoker
Throws:
java.lang.Exception

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

start

public void start()
           throws java.io.IOException
Starts the invoker.

Specified by:
start in interface ServerInvokerMBean
Specified by:
start in interface SocketServerInvokerMBean
Overrides:
start in class ServerInvoker
Throws:
java.io.IOException

createServerSocket

protected java.net.ServerSocket createServerSocket(int serverBindPort,
                                                   int backlog,
                                                   java.net.InetAddress bindAddress)
                                            throws java.io.IOException
Throws:
java.io.IOException

createServerSockets

protected void createServerSockets()
                            throws java.io.IOException
Throws:
java.io.IOException

configureServerSocket

protected void configureServerSocket(java.net.ServerSocket ss)
                              throws java.net.SocketException
Throws:
java.net.SocketException

getThreadName

protected java.lang.String getThreadName(int i)

destroy

public void destroy()
Description copied from class: ServerInvoker
Destory the invoker permanently.

Specified by:
destroy in interface ServerInvokerMBean
Overrides:
destroy in class ServerInvoker

stop

public void stop()
Stops the invoker.

Specified by:
stop in interface ServerInvokerMBean
Specified by:
stop in interface SocketServerInvokerMBean
Overrides:
stop in class ServerInvoker

cleanup

protected void cleanup()

getReceiveBufferSize

public int getReceiveBufferSize()

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)

getReuseAddress

public boolean getReuseAddress()
Indicates if SO_REUSEADDR is enabled on server sockets Default is true.


setReuseAddress

public void setReuseAddress(boolean reuse)
Sets if SO_REUSEADDR is enabled on server sockets. Default is true.

Parameters:
reuse -

isKeepAlive

public boolean isKeepAlive()

setKeepAlive

public void setKeepAlive(boolean keepAlive)

isOOBInline

public boolean isOOBInline()

setOOBInline

public void setOOBInline(boolean inline)

getSendBufferSize

public int getSendBufferSize()

setSendBufferSize

public void setSendBufferSize(int sendBufferSize)

isSoLinger

public boolean isSoLinger()

getSoLingerDuration

public int getSoLingerDuration()

setSoLinger

public void setSoLinger(boolean soLinger)

setSoLingerDuration

public void setSoLingerDuration(int soLingerDuration)

getTrafficClass

public int getTrafficClass()

setTrafficClass

public void setTrafficClass(int trafficClass)

getCurrentThreadPoolSize

public int getCurrentThreadPoolSize()
Specified by:
getCurrentThreadPoolSize in interface SocketServerInvokerMBean
Returns:
Value of property serverBindPort.

getCurrentClientPoolSize

public int getCurrentClientPoolSize()
Specified by:
getCurrentClientPoolSize in interface SocketServerInvokerMBean
Returns:
Value of property serverBindPort.

getNumAcceptThreads

public int getNumAcceptThreads()
Getter for property numAcceptThreads

Specified by:
getNumAcceptThreads in interface SocketServerInvokerMBean
Returns:
The number of threads that exist for accepting client connections

setNumAcceptThreads

public void setNumAcceptThreads(int size)
Setter for property numAcceptThreads

Specified by:
setNumAcceptThreads in interface SocketServerInvokerMBean
Parameters:
size - The number of threads that exist for accepting client connections

getMaxPoolSize

public int getMaxPoolSize()
Setter for max pool size. The number of server threads for processing client. The default is 300.

Specified by:
getMaxPoolSize in interface SocketServerInvokerMBean
Returns:

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
The number of server threads for processing client. The default is 300.

Specified by:
setMaxPoolSize in interface SocketServerInvokerMBean
Parameters:
maxPoolSize -

getBacklog

public int getBacklog()
Specified by:
getBacklog in interface SocketServerInvokerMBean

setBacklog

public void setBacklog(int backlog)
Specified by:
setBacklog in interface SocketServerInvokerMBean

getIdleTimeout

public int getIdleTimeout()

setIdleTimeout

public void setIdleTimeout(int idleTimeout)
Sets the timeout for idle threads to be removed from pool. If the value is greater than 0, then idle timeout will be activated, otherwise no idle timeouts will occur. By default, this value is -1.

Parameters:
idleTimeout - number of seconds before a idle thread is timed out.

configureSocket

protected void configureSocket(java.net.Socket s)
                        throws java.net.SocketException
Throws:
java.net.SocketException

processInvocation

protected void processInvocation(java.net.Socket socket)
                          throws java.lang.Exception
The acceptor thread should spend as little time as possbile doing any kind of operation, and under no circumstances should perform IO on the new socket, which can potentially block and lock up the server. For this reason, the acceptor thread should grab a worker thread and delegate all subsequent work to it.

Throws:
java.lang.Exception

isTransportBiDirectional

public boolean isTransportBiDirectional()
returns true if the transport is bi-directional in nature, for example, SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall for example).

Specified by:
isTransportBiDirectional in interface ServerInvokerMBean
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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 ServerInvoker


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