org.restlet.engine.http.connector

## Class Controller

- java.lang.Object
- - org.restlet.engine.http.connector.BaseTask
  - - org.restlet.engine.http.connector.Controller

All Implemented Interfaces:
  java.lang.Runnable

    public class Controller
    extends BaseTask

Controls the state of the server helper and its managed connections.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`Controller(BaseHelper<?> helper)` Constructor.

### Method Summary

Methods
`protected void` `controlConnections()` Control each connection for messages to read or write.
`protected void` `controlHelper()` Control the helper for inbound or outbound messages to handle.
`protected void` `execute(java.lang.Runnable task)` Executes the next task in a separate thread provided by the worker service, only if the worker service isn't busy.
`protected BaseHelper<?>` `getHelper()` Returns the parent connector helper.
`protected java.util.concurrent.ExecutorService` `getWorkerService()` Returns the helper's worker service.
`boolean` `isOverloaded()` Indicates if the controller is overloaded.
`protected boolean` `isWorkerServiceFull()` Indicates if the helper's worker service is fully busy and can't accept more tasks.
`void` `run()` Listens on the given server socket for incoming connections.
`void` `setOverloaded(boolean overloaded)` Indicates if the controller is overloaded.

### Methods inherited from class org.restlet.engine.http.connector.BaseTask

`isRunning, setRunning`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Controller

    public Controller(BaseHelper<?> helper)

Constructor.

Parameters:
  `helper` - The parent connector helper.

### Method Detail

#### controlConnections

    protected void controlConnections()
                               throws java.io.IOException

Control each connection for messages to read or write.

Throws:
  `java.io.IOException`

#### controlHelper

    protected void controlHelper()

Control the helper for inbound or outbound messages to handle.

#### execute

    protected void execute(java.lang.Runnable task)

Executes the next task in a separate thread provided by the worker service, only if the worker service isn't busy.

Parameters:
  `task` - The next task to execute.

#### getHelper

    protected BaseHelper<?> getHelper()

Returns the parent connector helper.

Returns:
  The parent connector helper.

#### getWorkerService

    protected java.util.concurrent.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.

#### isWorkerServiceFull

    protected boolean isWorkerServiceFull()

Indicates if the helper's worker service is fully busy and can't accept more tasks.

Returns:
  True if the helper's worker service is fully busy.

#### 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.