wt.method
Class MethodServerImpl
java.lang.Object
java.rmi.server.RemoteObject
java.rmi.server.RemoteServer
wt.util.RMIServer
wt.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
Constructor Summary |
MethodServerImpl(boolean stop_when_unreferenced)
Construct a RMI Method Server object. |
Methods inherited from class wt.util.RMIServer |
clone, exportObject, exportObject, exportObject, getClientSocketFactory, getPort, getServerSocketFactory, getStub, isHostInList, isLocalHost, setPort, writeReplace |
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
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
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()