org.jboss.remoting
Class ServerInvoker

java.lang.Object
  extended byorg.jboss.remoting.AbstractInvoker
      extended byorg.jboss.remoting.ServerInvoker
All Implemented Interfaces:
Invoker, ServerInvokerMBean
Direct Known Subclasses:
RMIServerInvoker, SocketServerInvoker, WebServerInvoker

public abstract class ServerInvoker
extends AbstractInvoker
implements ServerInvokerMBean

ServerInvoker is the server-side part of a remote Invoker. The ServerInvoker implementation is responsible for calling transport, depending on how the protocol receives the incoming data.

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

Field Summary
protected  java.util.Map callbackHandlers
           
static java.lang.String CLIENT_CONNECT_ADDRESS_KEY
           
static java.lang.String CLIENT_CONNECT_PORT_KEY
           
static java.lang.String CLIENT_LEASE_PERIOD
           
protected  java.util.Map clientCallbackListener
           
static int DEFAULT_CLIENT_LEASE_PERIOD
          The default lease period for clients.
protected  java.util.Map handlers
           
static int MAX_NUM_ONEWAY_THREADS
          The max number of worker threads to be used in the pool for processing one way calls on the server side.
static java.lang.String MAX_NUM_ONEWAY_THREADS_KEY
           
static java.lang.String ONEWAY_THREAD_POOL_CLASS_KEY
           
static java.lang.String SERVER_BIND_ADDRESS_KEY
           
static java.lang.String SERVER_BIND_PORT_KEY
           
static java.lang.String SERVER_SOCKET_FACTORY
           
static java.lang.String TIMEOUT
           
 
Fields inherited from class org.jboss.remoting.AbstractInvoker
classbyteloader, configuration, localServerLocators, locator, log, serializationType
 
Constructor Summary
ServerInvoker(InvokerLocator locator)
           
ServerInvoker(InvokerLocator locator, java.util.Map configuration)
           
 
Method Summary
 void addConnectionListener(ConnectionListener listener)
           
 ServerInvocationHandler addInvocationHandler(java.lang.String subsystem, ServerInvocationHandler handler)
          add a server invocation handler for a particular subsystem.
 void create()
           
protected  javax.net.ServerSocketFactory createServerSocketFactory()
           
 void destroy()
          destory the invoker permanently
 java.lang.String getClientConnectAddress()
           
 int getClientConnectPort()
           
 java.util.Map getConfiguration()
          Gets teh server invoker's transport specific configuration.
 java.lang.String getDataType()
          Will get the data type for the marshaller factory so know which marshaller to get to marshal the data.
protected abstract  java.lang.String getDefaultDataType()
           
protected  javax.net.ServerSocketFactory getDefaultServerSocketFactory()
          Gets the default server socket factory to use for the server invoker.
 ServerInvocationHandler getInvocationHandler(java.lang.String subsystem)
          get a ServerInvocationHandler for a given subsystem type
 ServerInvocationHandler[] getInvocationHandlers()
          return an array of the server invocation handlers
 long getLeasePeriod()
           
 int getMaxNumberOfOnewayThreads()
           
 java.lang.String getMBeanObjectName()
          Returns the String for the object name to be used for the invoker.
 javax.management.MBeanServer getMBeanServer()
           
 org.jboss.util.threadpool.ThreadPool getOnewayThreadPool()
           
 java.lang.String getServerBindAddress()
           
 int getServerBindPort()
           
 javax.net.ServerSocketFactory getServerSocketFactory()
           
 java.lang.String[] getSupportedSubsystems()
          return array of keys for each subsystem this invoker can handle
 int getTimeout()
           
 boolean hasInvocationHandler(java.lang.String subsystem)
          return true if a server invocation handler has been registered for this subsystem
 java.lang.Object invoke(InvocationRequest invocation)
          Processes invocation request depending on the invocation type (internal, name based, oneway, etc).
 java.lang.Object invoke(java.lang.Object invoke)
           
 boolean isStarted()
          return true if the server invoker is started, false if not
protected  void postProcess(java.lang.String sessionId, java.lang.Object param, java.util.Map payload, InvokerLocator locator)
          called after an invocation
protected  void preProcess(java.lang.String sessionId, ClassBytes arg, java.util.Map payload, InvokerLocator locator)
          called prior to an invocation
 void removeCallbackListener(java.lang.String subsystem, InvokerCallbackHandler callbackHandler)
           
 void removeConnectionListener(ConnectionListener listener)
           
 ServerInvocationHandler removeInvocationHandler(java.lang.String subsystem)
          remove a subsystem invocation handler
 void setClientConnectAddress(java.lang.String clientConnectAddress)
          This method should only be called by the service controller when this invoker is specified within the Connector configuration of a service xml.
 void setClientConnectPort(int clientConnectPort)
           
 void setConfiguration(java.util.Map configuration)
          Sets the server invoker's transport specific configuration.
 void setLeasePeriod(long leasePeriodValue)
           
 void setMaxNumberOfOnewayThreads(int numOfThreads)
           
 void setMBeanServer(javax.management.MBeanServer server)
           
 void setOnewayThreadPool(org.jboss.util.threadpool.ThreadPool pool)
           
 void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
           
 void setTimeout(int timeout)
           
protected  void setup()
           
 void start()
          subclasses should override to provide any specific start logic
 void stop()
          subclasses should override to provide any specific stop logic
 
Methods inherited from class org.jboss.remoting.AbstractInvoker
addClientLocator, getClassLoader, getClientLocator, getLocator, getSerializationType, setClassLoader, setSerializationType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.ServerInvokerMBean
isTransportBiDirectional
 

Field Detail

MAX_NUM_ONEWAY_THREADS_KEY

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

ONEWAY_THREAD_POOL_CLASS_KEY

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

SERVER_BIND_ADDRESS_KEY

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

CLIENT_CONNECT_ADDRESS_KEY

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

SERVER_BIND_PORT_KEY

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

CLIENT_CONNECT_PORT_KEY

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

CLIENT_LEASE_PERIOD

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

TIMEOUT

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

SERVER_SOCKET_FACTORY

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

MAX_NUM_ONEWAY_THREADS

public static final int MAX_NUM_ONEWAY_THREADS
The max number of worker threads to be used in the pool for processing one way calls on the server side. Value is is 100.

See Also:
Constant Field Values

DEFAULT_CLIENT_LEASE_PERIOD

public static final int DEFAULT_CLIENT_LEASE_PERIOD
The default lease period for clients. This is the number of milliseconds that a client will be required to renew their lease with the server. The default value is 5 seconds.

See Also:
Constant Field Values

handlers

protected java.util.Map handlers

callbackHandlers

protected java.util.Map callbackHandlers

clientCallbackListener

protected java.util.Map clientCallbackListener
Constructor Detail

ServerInvoker

public ServerInvoker(InvokerLocator locator)

ServerInvoker

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

setup

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

setServerSocketFactory

public void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)

getServerSocketFactory

public javax.net.ServerSocketFactory getServerSocketFactory()

createServerSocketFactory

protected javax.net.ServerSocketFactory createServerSocketFactory()
                                                           throws java.io.IOException
Throws:
java.io.IOException

getDefaultServerSocketFactory

protected javax.net.ServerSocketFactory getDefaultServerSocketFactory()
Gets the default server socket factory to use for the server invoker. The intention is this method will be overridden by sub-classes for their specific defaults.

Returns:

setTimeout

public void setTimeout(int timeout)
Specified by:
setTimeout in interface ServerInvokerMBean

getTimeout

public int getTimeout()
Specified by:
getTimeout in interface ServerInvokerMBean

addConnectionListener

public void addConnectionListener(ConnectionListener listener)

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)

setLeasePeriod

public void setLeasePeriod(long leasePeriodValue)

getLeasePeriod

public long getLeasePeriod()

getClientConnectAddress

public java.lang.String getClientConnectAddress()
Specified by:
getClientConnectAddress in interface ServerInvokerMBean

getClientConnectPort

public int getClientConnectPort()
Specified by:
getClientConnectPort in interface ServerInvokerMBean

setClientConnectPort

public void setClientConnectPort(int clientConnectPort)
Specified by:
setClientConnectPort in interface ServerInvokerMBean

setClientConnectAddress

public void setClientConnectAddress(java.lang.String clientConnectAddress)
This method should only be called by the service controller when this invoker is specified within the Connector configuration of a service xml. Calling this directly will have no effect, as will be used in building the locator uri that is published for detection and this happens when the invoker is first created and started (after that, no one will be aware of a change).

Specified by:
setClientConnectAddress in interface ServerInvokerMBean

getServerBindAddress

public java.lang.String getServerBindAddress()
Specified by:
getServerBindAddress in interface ServerInvokerMBean

getServerBindPort

public int getServerBindPort()
Specified by:
getServerBindPort in interface ServerInvokerMBean

setMaxNumberOfOnewayThreads

public void setMaxNumberOfOnewayThreads(int numOfThreads)

getMaxNumberOfOnewayThreads

public int getMaxNumberOfOnewayThreads()

getOnewayThreadPool

public org.jboss.util.threadpool.ThreadPool getOnewayThreadPool()

setOnewayThreadPool

public void setOnewayThreadPool(org.jboss.util.threadpool.ThreadPool pool)

getMBeanServer

public javax.management.MBeanServer getMBeanServer()

setMBeanServer

public void setMBeanServer(javax.management.MBeanServer server)

hasInvocationHandler

public boolean hasInvocationHandler(java.lang.String subsystem)
return true if a server invocation handler has been registered for this subsystem

Parameters:
subsystem -
Returns:

getSupportedSubsystems

public java.lang.String[] getSupportedSubsystems()
return array of keys for each subsystem this invoker can handle

Returns:

getInvocationHandlers

public ServerInvocationHandler[] getInvocationHandlers()
return an array of the server invocation handlers

Returns:

addInvocationHandler

public ServerInvocationHandler addInvocationHandler(java.lang.String subsystem,
                                                    ServerInvocationHandler handler)
add a server invocation handler for a particular subsystem. Typically, subsystems are defined in org.jboss.remoting.Subsystem, however, this can be any string that the caller knows about.

Parameters:
subsystem -
handler -
Returns:
previous ServerInvocationHandler with the same sybsystem value (case insensitive) or null if a previous one did not exist.

removeInvocationHandler

public ServerInvocationHandler removeInvocationHandler(java.lang.String subsystem)
remove a subsystem invocation handler

Parameters:
subsystem -

getInvocationHandler

public ServerInvocationHandler getInvocationHandler(java.lang.String subsystem)
get a ServerInvocationHandler for a given subsystem type

Parameters:
subsystem -
Returns:

invoke

public java.lang.Object invoke(java.lang.Object invoke)
                        throws java.io.IOException
Throws:
java.io.IOException

getDataType

public java.lang.String getDataType()
Will get the data type for the marshaller factory so know which marshaller to get to marshal the data. Will first check the locator uri for a 'datatype' parameter and take that value if it exists. Otherwise, will use the default datatype for the client invoker, based on transport.

Specified by:
getDataType in interface ServerInvokerMBean
Returns:

getDefaultDataType

protected abstract java.lang.String getDefaultDataType()

invoke

public java.lang.Object invoke(InvocationRequest invocation)
                        throws java.lang.Throwable
Processes invocation request depending on the invocation type (internal, name based, oneway, etc). Can be called on directly when client and server are local to one another (by-passing serialization)

Parameters:
invocation -
Returns:
Throws:
java.lang.Throwable

preProcess

protected void preProcess(java.lang.String sessionId,
                          ClassBytes arg,
                          java.util.Map payload,
                          InvokerLocator locator)
called prior to an invocation

Parameters:
sessionId -
payload -
locator -

postProcess

protected void postProcess(java.lang.String sessionId,
                           java.lang.Object param,
                           java.util.Map payload,
                           InvokerLocator locator)
called after an invocation

Parameters:
sessionId -
payload -
locator -

create

public void create()
Specified by:
create in interface ServerInvokerMBean

start

public void start()
           throws java.io.IOException
subclasses should override to provide any specific start logic

Specified by:
start in interface ServerInvokerMBean
Throws:
java.io.IOException

isStarted

public boolean isStarted()
return true if the server invoker is started, false if not

Specified by:
isStarted in interface ServerInvokerMBean
Returns:

stop

public void stop()
subclasses should override to provide any specific stop logic

Specified by:
stop in interface ServerInvokerMBean

destroy

public void destroy()
destory the invoker permanently

Specified by:
destroy in interface ServerInvokerMBean

setConfiguration

public void setConfiguration(java.util.Map configuration)
Sets the server invoker's transport specific configuration. Will need to set before calling start() method (or at least stop() and start() again) before configurations will take affect.

Specified by:
setConfiguration in interface ServerInvokerMBean
Parameters:
configuration -

getConfiguration

public java.util.Map getConfiguration()
Gets teh server invoker's transport specific configuration.

Specified by:
getConfiguration in interface ServerInvokerMBean
Returns:

getMBeanObjectName

public java.lang.String getMBeanObjectName()
Returns the String for the object name to be used for the invoker.

Returns:

removeCallbackListener

public void removeCallbackListener(java.lang.String subsystem,
                                   InvokerCallbackHandler callbackHandler)


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