Search in sources :

Example 1 with RoboRequestFactory

use of com.robo4j.socket.http.request.RoboRequestFactory in project robo4j by Robo4J.

the class ReadSelectionKeyHandler method handle.

@Override
public SelectionKey handle() {
    SocketChannel channel = (SocketChannel) key.channel();
    lock.lock();
    try {
        final HttpDecoratedRequest decoratedRequest = channelRequestBuffer.getHttpDecoratedRequestByChannel(channel);
        final RoboRequestFactory factory = new RoboRequestFactory(codecRegistry);
        final RoboRequestCallable callable = new RoboRequestCallable(context, serverContext, decoratedRequest, factory);
        final Future<HttpResponseProcess> futureResult = context.getScheduler().submit(callable);
        final HttpResponseProcess result = extractRoboResponseProcess(futureResult);
        outBuffers.put(key, result);
        registerSelectionKey(channel);
        return key;
    } catch (IOException e) {
        throw new SocketException(e.getMessage());
    } finally {
        lock.unlock();
    }
}
Also used : HttpDecoratedRequest(com.robo4j.socket.http.message.HttpDecoratedRequest) SocketChannel(java.nio.channels.SocketChannel) SocketException(com.robo4j.socket.http.SocketException) RoboRequestCallable(com.robo4j.socket.http.request.RoboRequestCallable) HttpResponseProcess(com.robo4j.socket.http.request.HttpResponseProcess) IOException(java.io.IOException) RoboRequestFactory(com.robo4j.socket.http.request.RoboRequestFactory)

Aggregations

SocketException (com.robo4j.socket.http.SocketException)1 HttpDecoratedRequest (com.robo4j.socket.http.message.HttpDecoratedRequest)1 HttpResponseProcess (com.robo4j.socket.http.request.HttpResponseProcess)1 RoboRequestCallable (com.robo4j.socket.http.request.RoboRequestCallable)1 RoboRequestFactory (com.robo4j.socket.http.request.RoboRequestFactory)1 IOException (java.io.IOException)1 SocketChannel (java.nio.channels.SocketChannel)1