### php.java.bridge.http

# Class ContextServer

- `java.lang.Object`

- `php.java.bridge.http.ContextServer`

Implemented Interfaces:
  java.lang.Runnable

`public class ContextServer`
`extends java.lang.Object`
`implements java.lang.Runnable`

This class manages the ContextRunners. It pulls a ContextRunner from the list of available runners and invokes it. We currently check only if the number of runners requested is less than or equal to the number of runners created by the servlet requests.

## Constructor Summary

`ContextServer(ThreadPool threadPool)`
  Create a new ContextServer using the ThreadPool.

## Method Summary

`void`

`destroy()`
  Destroy the server

`boolean`

`getNext()`
  Get the next runnable

`ISocketFactory`

`getSocket()`

`boolean`

`isAvailable()`
  Check if the ContextServer is ready, i.e.

`void`

`run()`
  This method will be called by whoever wishes to run your class implementing Runnable.

`void`

`schedule()`
  Add a runnable to the queue.

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

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

## Constructor Details

### ContextServer

    public ContextServer(ThreadPool threadPool)

> Create a new ContextServer using the ThreadPool.

> Parameters:
>   `threadPool` - Obtain runnables from this pool. If null, new threads will be created.

## Method Details

### destroy

    public void destroy()

> Destroy the server

### getNext

    public boolean getNext()

> Get the next runnable

> Returns:
>   True if there is a runnable in the queue, false otherwise.

### getSocket

    public ISocketFactory getSocket()

> Returns:
>   Returns the server socket.

### isAvailable

    public boolean isAvailable()

> Check if the ContextServer is ready, i.e. it has created a server socket.

> Returns:
>   true if there's a server socket listening, false otherwise.

> See Also:
>   `getSocket()`

### run

    public void run()

> This method will be called by whoever wishes to run your class implementing Runnable. Note that there are no restrictions on what you are allowed to do in the run method, except that you cannot throw a checked exception.
> Specified by:
>   run in interface java.lang.Runnable

### schedule

    public void schedule()

> Add a runnable to the queue.

> See Also:
>   `getNext()`