Class ContainerServer

java.lang.Object
org.simpleframework.http.core.ContainerServer
All Implemented Interfaces:
Server

public class ContainerServer extends Object implements Server
The ContainerServer object provides a processor that dispatch requests from a connected pipeline. SSL connections and plain connections can be processed by this implementation. It collects data from the connected pipelines and constructs the requests and responses used to dispatch to the container.

In order to process the requests this uses two thread pools. One is used to collect data from the pipelines and create the requests. The other is used to service those requests. Such an architecture ensures that the serving thread does not have to deal with I/O operations. All data is consumed before it is serviced.

Author:
Niall Gallagher
  • Constructor Details

    • ContainerServer

      public ContainerServer(Container container) throws IOException
      Constructor for the ContainerServer object. The processor created will collect HTTP requests from the pipelines provided and dispatch those requests to the provided container.
      Parameters:
      container - this is the container used to service requests
      Throws:
      IOException
    • ContainerServer

      public ContainerServer(Container container, int count) throws IOException
      Constructor for the ContainerServer object. The processor created will collect HTTP requests from the pipelines provided and dispatch those requests to the provided container.
      Parameters:
      container - this is the container used to service requests
      count - this is the number of threads used for each pool
      Throws:
      IOException
    • ContainerServer

      public ContainerServer(Container container, Allocator allocator) throws IOException
      Constructor for the ContainerServer object. The processor created will collect HTTP requests from the pipelines provided and dispatch those requests to the provided container.
      Parameters:
      container - this is the container used to service requests
      allocator - this is the allocator used to create buffers
      Throws:
      IOException
    • ContainerServer

      public ContainerServer(Container container, Allocator allocator, int count) throws IOException
      Constructor for the ContainerServer object. The processor created will collect HTTP requests from the pipelines provided and dispatch those requests to the provided container.
      Parameters:
      container - this is the container used to service requests
      allocator - this is the allocator used to create buffers
      count - this is the number of threads used for each pool
      Throws:
      IOException
  • Method Details

    • process

      public void process(Socket socket) throws IOException
      Used to process the Socket which is a full duplex communication link that may contain several HTTP requests. This will be used to read the requests from the Socket and to pass these requests to a Container for processing.

      Typical usage of this method is to accept multiple pipeline objects, each representing a unique HTTP channel to the client, and process requests from those pipelines concurrently.

      Specified by:
      process in interface Server
      Parameters:
      socket - this is the connected HTTP pipeline to process
      Throws:
      IOException
    • stop

      public void stop() throws IOException
      This method is used to stop the Processor such that it will accept no more pipelines. Stopping the processor ensures that all resources occupied will be released. This is required so that all threads are stopped, and all memory is released.

      Typically this method is called once all connections to the server have been stopped. As a final act of shutting down the entire server all threads must be stopped, this allows collection of unused memory and the closing of file and socket resources.

      Specified by:
      stop in interface Server
      Throws:
      IOException