org.restlet.engine.connector
Class Controller

java.lang.Object
  extended by org.restlet.engine.connector.Controller
Direct Known Subclasses:
ConnectionController

public abstract class Controller
extends Object

Controls the IO work of parent connector helper.

Author:
Jerome Louvel

Field Summary
protected  ConnectionHelper<?> helper
          The parent connector helper.
protected  boolean overloaded
          Indicates if the controller is overloaded.
protected  boolean running
          Indicates if the task is running.
 
Constructor Summary
Controller(ConnectionHelper<?> helper)
          Constructor.
 
Method Summary
protected  void doInit()
          Initializes the controller before entering the control loop.
protected  void doRelease()
          Method called-back with the controller stops running.
protected  void doRun(long sleepTime)
          Do the actual controller work.
protected  ConnectionHelper<?> getHelper()
          Returns the parent connector helper.
protected  ExecutorService getWorkerService()
          Returns the helper's worker service.
 boolean isOverloaded()
          Indicates if the controller is overloaded.
protected  boolean isRunning()
          Indicates if the task is running.
 void run()
          Listens on the given server socket for incoming connections.
 void setOverloaded(boolean overloaded)
          Indicates if the controller is overloaded.
 void shutdown()
          Abort the controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helper

protected final ConnectionHelper<?> helper
The parent connector helper.


overloaded

protected boolean overloaded
Indicates if the controller is overloaded.


running

protected boolean running
Indicates if the task is running.

Constructor Detail

Controller

public Controller(ConnectionHelper<?> helper)
Constructor.

Parameters:
helper - The parent connector helper.
Method Detail

doInit

protected void doInit()
Initializes the controller before entering the control loop.


doRelease

protected void doRelease()
Method called-back with the controller stops running.


doRun

protected void doRun(long sleepTime)
              throws IOException
Do the actual controller work. Called by the run() to provide an easy method to overload.

Parameters:
sleepTime - The maximum amount of sleep time.
Throws:
IOException

getHelper

protected ConnectionHelper<?> getHelper()
Returns the parent connector helper.

Returns:
The parent connector helper.

getWorkerService

protected ExecutorService getWorkerService()
Returns the helper's worker service.

Returns:
The helper's worker service.

isOverloaded

public boolean isOverloaded()
Indicates if the controller is overloaded.

Returns:
True if the controller is overloaded.

isRunning

protected boolean isRunning()
Indicates if the task is running.

Returns:
True if the task is running.

run

public void run()
Listens on the given server socket for incoming connections.


setOverloaded

public void setOverloaded(boolean overloaded)
Indicates if the controller is overloaded.

Parameters:
overloaded - True if the controller is overloaded.

shutdown

public void shutdown()
Abort the controller.



Copyright © 2005-2013 Restlet.