wt.method
Class MethodServerImpl

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended bywt.util.RMIServer
              extended bywt.method.MethodServerImpl
All Implemented Interfaces:
ManagedServer, MethodServer, Remote, Runnable, Serializable, Unreferenced

public class MethodServerImpl
extends RMIServer
implements MethodServer, ManagedServer, Unreferenced, Runnable

The method server object. This is an RMI server object that exposes method operations to remote clients via the RemoteMethodServer class.

See Also:
RemoteMethodServer, Serialized Form

Field Summary
private static int ACTIVE_CONTEXT_FAILOVER
           
private static boolean CHECK_REMOTE_ACCESS
           
private  Object getNextServerLock
           
private static Serializable JMX_CONNECT_INFO
           
private static int MAX_REDIRECTS
           
private static String METHOD_SERVER_JMX_HOOK_CLASSNAME
           
private  MethodServer nextServer
           
private  String previousClientHost
           
private static boolean PRINT_CHECKED_EXCEPTIONS
           
private  Random random
           
private  boolean ready
           
private static String RESOURCE
           
private static int RMI_OBJ_ID
           
private static int RMI_SOCKETS_FAILOVER
           
private static String SERVICE_NAME
           
private static Date startDate
           
private  boolean stopWhenUnreferenced
           
private static int totalInvokeCalls
           
private static boolean VERBOSE_SERVER
           
 
Fields inherited from class wt.util.RMIServer
csf, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface wt.method.MethodServer
SERVER_NAME, versionID
 
Fields inherited from interface wt.manager.ManagedServer
versionID
 
Constructor Summary
MethodServerImpl(boolean stop_when_unreferenced)
          Construct a RMI Method Server object.
 
Method Summary
protected  void checkAccess()
          Method to validate access to secure methods such as stop.
 MethodServerInfo getInfo()
          Get usage information.
static Serializable getJmxConnectInfo()
           
static MethodServerInfo getLocalInfo()
           
private  Random getRandom()
           
static Date getStartDate()
           
static int getTotalInvokeCalls()
           
private static void incrementTotalInvokeCalls()
           
 MethodResult invoke(MethodArgs args)
          Dynamically invoke a given method.
private  MethodServer nextMethodServer()
           
 void ping()
          Used to check if this server object is alive
private  void printException(Throwable t, MethodArgs args)
           
 void ready()
           
private  boolean redirect(MethodArgs args)
           
 void run()
           
 void stop()
          Stop this method server.
 void unreferenced()
          Called when this RMI server object is no longer referenced by any RMI clients.
private  void waitUntilReady()
           
 
Methods inherited from class wt.util.RMIServer
clone, exportObject, exportObject, exportObject, getClientSocketFactory, getPort, getServerSocketFactory, getStub, isHostInList, isLocalHost, setPort, writeReplace
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

VERBOSE_SERVER

private static final boolean VERBOSE_SERVER

PRINT_CHECKED_EXCEPTIONS

private static final boolean PRINT_CHECKED_EXCEPTIONS

CHECK_REMOTE_ACCESS

private static final boolean CHECK_REMOTE_ACCESS

SERVICE_NAME

private static final String SERVICE_NAME

RMI_OBJ_ID

private static final int RMI_OBJ_ID

METHOD_SERVER_JMX_HOOK_CLASSNAME

private static final String METHOD_SERVER_JMX_HOOK_CLASSNAME

JMX_CONNECT_INFO

private static final Serializable JMX_CONNECT_INFO

RMI_SOCKETS_FAILOVER

private static final int RMI_SOCKETS_FAILOVER

ACTIVE_CONTEXT_FAILOVER

private static final int ACTIVE_CONTEXT_FAILOVER

MAX_REDIRECTS

private static final int MAX_REDIRECTS

startDate

private static Date startDate

totalInvokeCalls

private static int totalInvokeCalls

stopWhenUnreferenced

private boolean stopWhenUnreferenced

nextServer

private volatile MethodServer nextServer

getNextServerLock

private Object getNextServerLock

random

private Random random

ready

private boolean ready

previousClientHost

private String previousClientHost
Constructor Detail

MethodServerImpl

public MethodServerImpl(boolean stop_when_unreferenced)
                 throws RemoteException
Construct a RMI Method Server object. The stop_when_unreferenced argument indicates if WTContext.stop should be called when this RMI server object becomes unreferenced by any remote client (including registry).

Parameters:
stop_when_unreferenced - call WTContext.stop when unreferenced
Method Detail

incrementTotalInvokeCalls

private static void incrementTotalInvokeCalls()

stop

public void stop()
Stop this method server. WTContext.stop is called to signal shutdown. Only calls originating from the local host will be honored.

Specified by:
stop in interface ManagedServer

ping

public void ping()
Used to check if this server object is alive

Specified by:
ping in interface ManagedServer

invoke

public MethodResult invoke(MethodArgs args)
                    throws ClassNotFoundException,
                           NoSuchMethodException,
                           ServerLoadException
Dynamically invoke a given method. This is the primary interface to the method server. Arguments and results are passed in special container objects that implement custom marshaling to pass additional context and dispatch the target method while the output marshaling stream is available for sending progress feedback.

Specified by:
invoke in interface MethodServer
Parameters:
args - object containing the target method and its arguments
Returns:
result object containing return value or exception
Throws:
ClassNotFoundException
NoSuchMethodException
ServerLoadException

redirect

private boolean redirect(MethodArgs args)

nextMethodServer

private MethodServer nextMethodServer()

getRandom

private Random getRandom()

run

public void run()
Specified by:
run in interface Runnable

printException

private void printException(Throwable t,
                            MethodArgs args)

getLocalInfo

public static MethodServerInfo getLocalInfo()

getStartDate

public static Date getStartDate()

getJmxConnectInfo

public static Serializable getJmxConnectInfo()

getTotalInvokeCalls

public static int getTotalInvokeCalls()

getInfo

public MethodServerInfo getInfo()
Get usage information.

Specified by:
getInfo in interface MethodServer

unreferenced

public void unreferenced()
Called when this RMI server object is no longer referenced by any RMI clients. If this server object was constructed with stop_when_unreferenced set to true, then WTContext.stop is called to trigger shutdown.

Specified by:
unreferenced in interface Unreferenced

checkAccess

protected void checkAccess()
Method to validate access to secure methods such as stop. This implementation assumes this is an RMI call and allows access only from clients that are running on the local (server) host.

Throws:
SecurityException - if check fails and/or access is denied

waitUntilReady

private void waitUntilReady()

ready

public void ready()