com.objectwave.simpleSockets
Class MutexServer
java.lang.Object
|
+--com.objectwave.simpleSockets.SimpleServer
|
+--com.objectwave.simpleSockets.WatchdogServer
|
+--com.objectwave.simpleSockets.MutexServer
- All Implemented Interfaces:
- java.lang.Runnable
- public class MutexServer
- extends WatchdogServer
This extension of the WatchdogServer manages mutual exclusion across
process boundaries. It's actually a pretty simple procedure, and this
implementation doesn't implement many safeguards. A client will
connect briefly, and send a string in the format
"request:", where is a string that has some meaning
among the clients. The request will prompt the server to
return "granted" if and only if is either currently associated
with the client, or if it is not associated with any clients. It will
otherwise return "denied". Any other response is an internal error.
The client can also send a "release:" message, which will
cause the server to destroy any association between the client and
.
This method will always succeed (having no associated id to destroy is
not an error condition).
The client can also send a "releaseAll" message, which will, well,
release all string associated with the client'd is.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MutexServer
public MutexServer()
MutexServer
public MutexServer(int port)
clientDied
protected void clientDied(long id)
- Overrides:
clientDied
in class WatchdogServer
clientLeft
protected void clientLeft(long id)
- Overrides:
clientLeft
in class WatchdogServer
main
public static void main(java.lang.String[] args)
- Fire up the mutual exclusion server.
- Parameters:
args
-
newClient
protected void newClient(long id)
- Overrides:
newClient
in class WatchdogServer
processGoodbye
protected void processGoodbye(long id)
- Overrides:
processGoodbye
in class WatchdogServer
processMessage
protected java.lang.String processMessage(long id,
java.lang.String message)
- Overrides:
processMessage
in class WatchdogServer
releaseAll
protected void releaseAll(long clientId)