com.javageeks.gjas.services
Class ThreadedServer
java.lang.Object
|
+--com.javageeks.gjas.services.ThreadedServer
- All Implemented Interfaces:
- java.io.Serializable, Service
- Direct Known Subclasses:
- SocketServer
- public abstract class ThreadedServer
- extends java.lang.Object
- implements Service
ThreadedServer
- See Also:
- Serialized Form
Method Summary |
java.lang.String |
getInstanceID()
Return a String uniquely identifying this instance of the
Service; this String must be unique not just to the Service
class, but to the Service instance itself. |
java.lang.String |
getState()
Get the current state of the Service; must be one of the
following types: STOPPED, STARTING, RUNNING, STOPPING,
PAUSING, PAUSED, or RESUMING. |
java.lang.Thread |
getThread()
|
boolean |
isPaused()
|
void |
kill()
|
void |
pause()
Pause the Service. |
void |
resume()
Resume the Service. |
void |
setRunnable(java.lang.Runnable runnable)
|
void |
setState(java.lang.String val)
|
void |
setThread(java.lang.Thread thread)
|
boolean |
shouldStop()
|
void |
start()
Start the Service. |
void |
stop()
Stop the Service. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_paused
protected boolean m_paused
m_shouldStop
protected boolean m_shouldStop
ThreadedServer
public ThreadedServer()
start
public void start()
throws java.lang.Exception
- Description copied from interface:
Service
- Start the Service.
- Specified by:
start
in interface Service
stop
public void stop()
throws java.lang.Exception
- Description copied from interface:
Service
- Stop the Service.
- Specified by:
stop
in interface Service
kill
public void kill()
pause
public void pause()
throws java.lang.Exception
- Description copied from interface:
Service
- Pause the Service.
- Specified by:
pause
in interface Service
resume
public void resume()
throws java.lang.Exception
- Description copied from interface:
Service
- Resume the Service.
- Specified by:
resume
in interface Service
getState
public java.lang.String getState()
- Description copied from interface:
Service
- Get the current state of the Service; must be one of the
following types: STOPPED, STARTING, RUNNING, STOPPING,
PAUSING, PAUSED, or RESUMING.
- Specified by:
getState
in interface Service
setState
public void setState(java.lang.String val)
getInstanceID
public java.lang.String getInstanceID()
throws java.lang.Exception
- Description copied from interface:
Service
- Return a String uniquely identifying this instance of the
Service; this String must be unique not just to the Service
class, but to the Service instance itself. Suggested return
format is something like:
String instanceID = this.getClass().getName() + ":" +
getClassVersion() + ":" + System.currentTimeMillis();
Note that maintaining an "instance count" of the number of
instances of this class will fail, since all instances will
be maintained within their own ClassLoader, and static
members are stored on a per-ClassLoader basis.
- Specified by:
getInstanceID
in interface Service
isPaused
public boolean isPaused()
shouldStop
public boolean shouldStop()
setRunnable
public void setRunnable(java.lang.Runnable runnable)
throws java.lang.IllegalThreadStateException
setThread
public void setThread(java.lang.Thread thread)
throws java.lang.IllegalThreadStateException
getThread
public java.lang.Thread getThread()