Package org.simpleframework.http.core
Class ContainerSocketProcessor
- java.lang.Object
-
- org.simpleframework.http.core.ContainerSocketProcessor
-
- All Implemented Interfaces:
SocketProcessor
public class ContainerSocketProcessor extends java.lang.Object implements SocketProcessor
TheContainerSocketProcessor
object is a connector 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.
-
-
Field Summary
Fields Modifier and Type Field Description private SocketProcessor
adapter
This is used to deliver pipelines to the container.private TransportProcessor
processor
This is the transporter used to process the connections.
-
Constructor Summary
Constructors Constructor Description ContainerSocketProcessor(Container container)
Constructor for theContainerSocketProcessor
object.ContainerSocketProcessor(Container container, int count)
Constructor for theContainerSocketProcessor
object.ContainerSocketProcessor(Container container, int count, int select)
Constructor for theContainerSocketProcessor
object.ContainerSocketProcessor(Container container, Allocator allocator)
Constructor for theContainerSocketProcessor
object.ContainerSocketProcessor(Container container, Allocator allocator, int count)
Constructor for theContainerSocketProcessor
object.ContainerSocketProcessor(Container container, Allocator allocator, int count, int select)
Constructor for theContainerSocketProcessor
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(Socket socket)
This is used to consume HTTP messages that arrive on the socket and dispatch them to the internal container.void
stop()
This method is used to stop the connector in such a way that it will not accept and process any further messages.
-
-
-
Field Detail
-
processor
private final TransportProcessor processor
This is the transporter used to process the connections.
-
adapter
private final SocketProcessor adapter
This is used to deliver pipelines to the container.
-
-
Constructor Detail
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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:
java.io.IOException
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container, int count) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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 requestscount
- this is the number of threads used for each pool- Throws:
java.io.IOException
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container, int count, int select) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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 requestscount
- this is the number of threads used for each poolselect
- this is the number of selector threads to use- Throws:
java.io.IOException
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container, Allocator allocator) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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 requestsallocator
- this is the allocator used to create buffers- Throws:
java.io.IOException
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container, Allocator allocator, int count) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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 requestsallocator
- this is the allocator used to create bufferscount
- this is the number of threads used for each pool- Throws:
java.io.IOException
-
ContainerSocketProcessor
public ContainerSocketProcessor(Container container, Allocator allocator, int count, int select) throws java.io.IOException
Constructor for theContainerSocketProcessor
object. The connector 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 requestsallocator
- this is the allocator used to create bufferscount
- this is the number of threads used for each poolselect
- this is the number of selector threads to use- Throws:
java.io.IOException
-
-
Method Detail
-
process
public void process(Socket socket) throws java.io.IOException
This is used to consume HTTP messages that arrive on the socket and dispatch them to the internal container. Depending on whether the socket contains anSSLEngine
an SSL handshake may be performed before any HTTP messages are consumed. This can be called from multiple threads and does not block.- Specified by:
process
in interfaceSocketProcessor
- Parameters:
socket
- this is the connected HTTP pipeline to process- Throws:
java.io.IOException
-
stop
public void stop() throws java.io.IOException
This method is used to stop the connector in such a way that it will not accept and process any further messages. If there are resources to clean up they may be cleaned up asynchronously so that this method can return without blocking.- Specified by:
stop
in interfaceSocketProcessor
- Throws:
java.io.IOException
-
-