|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
org.sourceforge.jemm.comm.server.RPCServer
public class RPCServer
The RPCServer offers RPC interfaces to connecting clients. The server can handle multiple
client connections.
See EchoClient
/EchoServer
for an example of usage.
Released under the Apache License V2.0 license by the JEMM Project
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected java.util.Map<RPCClientId,ServerThread> |
clientThreads
The map of clientIds to active clients |
protected boolean |
closing
Used for graceful shutdown. |
protected ServerConnectionFactory |
connectionFactory
|
protected java.util.concurrent.CountDownLatch |
initialisationLatch
A latch to ensure server is ready when initialisation call returns. |
protected static org.apache.log4j.Logger |
LOG
|
protected java.util.concurrent.ExecutorService |
msgProccessingThreadPool
The thread pool for processing client call requests (shared among all clients) |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
RPCServer(ServerConnectionFactory connectionFactory,
java.util.concurrent.ExecutorService executorService)
Creates an RPCServer instance |
|
RPCServer(ServerConnectionFactory connectionFactory,
int noProcessingThreads)
Creates an RPCServer instance |
Method Summary | |
---|---|
void |
clientDisconnected(RPCClientId clientId)
Notification that a given client has disconnected. |
RPCClientId |
getClientId()
Used by called methods to find out ID of calling client. |
java.lang.Object |
getClientIF(RPCClientId clientId,
java.lang.Class<?> ifClass)
Retrieve a proxy for the given interface on the given client. |
void |
notifyNewClient(RPCClientId clientId,
java.lang.String clientAddress)
|
void |
registerInterface(java.lang.Class<?> targetIF,
java.lang.Object targetIFImpl)
Register an interface for RPC calls by clients. |
void |
run()
|
void |
setClientListener(ClientConnectionListener listener)
Sets the client listener to the given listener. |
void |
shutdown()
Request by the system for the server to be shutdown. |
void |
waitForInitialisation()
This method will pause the caller until the server is ready to start accepting connections. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.log4j.Logger LOG
protected java.util.Map<RPCClientId,ServerThread> clientThreads
protected java.util.concurrent.CountDownLatch initialisationLatch
protected boolean closing
protected java.util.concurrent.ExecutorService msgProccessingThreadPool
protected final ServerConnectionFactory connectionFactory
Constructor Detail |
---|
public RPCServer(ServerConnectionFactory connectionFactory, java.util.concurrent.ExecutorService executorService)
connectionFactory
- The connection factory for accepting client connections.executorService
- The executor used to service requests.public RPCServer(ServerConnectionFactory connectionFactory, int noProcessingThreads)
connectionFactory
- The connection factory for accepting client connections.noProcessingThreads
- The number of processing threads.Method Detail |
---|
public void clientDisconnected(RPCClientId clientId)
clientId
- The assigned id of the disconnected client.public RPCClientId getClientId()
public java.lang.Object getClientIF(RPCClientId clientId, java.lang.Class<?> ifClass)
clientId
- The id of the client.ifClass
- The required interface class.
public void notifyNewClient(RPCClientId clientId, java.lang.String clientAddress)
clientId
- The id of the new client.clientHostname
- The clients hostname.public void registerInterface(java.lang.Class<?> targetIF, java.lang.Object targetIFImpl)
targetIF
- The interface to offer to clients.targetIFImpl
- The server side implementation of the given interface.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setClientListener(ClientConnectionListener listener)
listener
- The listener to receive disconnection events.public void shutdown()
public void waitForInitialisation()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |