Examples of UriHttpAsyncRequestHandlerMapper


Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

    @Before
    public void setUp() throws Exception {
        initServer();
        this.serverHttpProc = new ImmutableHttpProcessor(
                new ResponseServer("TEST-SERVER/1.1"), new ResponseContent(), new ResponseConnControl());
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new HttpRequestHandler() {

            @Override
            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                final String content = "thank you very much";
                final NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
                response.setEntity(entity);
            }

        }));
        registry.register("/goodbye", new BasicAsyncRequestHandler(new HttpRequestHandler() {

            @Override
            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
                    final HttpContext context) throws HttpException, IOException {
                final String content = "and goodbye";
                final NStringEntity entity = new NStringEntity(content, ContentType.DEFAULT_TEXT);
                response.setEntity(entity);
                response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
            }

        }));
        registry.register("/echo", new BasicAsyncRequestHandler(new HttpRequestHandler() {

            @Override
            public void handle(
                    final HttpRequest request,
                    final HttpResponse response,
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

            public void failed(final Exception ex) {
            }

        };

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new HttpAsyncRequestHandler<HttpRequest>() {

            @Override
            public HttpAsyncRequestConsumer<HttpRequest> processRequest(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

                latch.countDown();
                return true;
            }
        };

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new HttpAsyncRequestHandler<HttpRequest>() {

            @Override
            public HttpAsyncRequestConsumer<HttpRequest> processRequest(
                    final HttpRequest request,
                    final HttpContext context) throws HttpException, IOException {
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

            httpProcessorCopy = b.build();
        }

        HttpAsyncRequestHandlerMapper handlerMapperCopy = this.handlerMapper;
        if (handlerMapperCopy == null) {
            final UriHttpAsyncRequestHandlerMapper reqistry = new UriHttpAsyncRequestHandlerMapper();
            if (handlerMap != null) {
                for (Map.Entry<String, HttpAsyncRequestHandler<?>> entry: handlerMap.entrySet()) {
                    reqistry.register(entry.getKey(), entry.getValue());
                }
            }
            handlerMapperCopy = reqistry;
        }
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

        final AtomicInteger closedServerConns = new AtomicInteger(0);

        this.client.setMaxPerRoute(connNo);
        this.client.setMaxTotal(connNo);

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        final HttpAsyncService serviceHandler = new HttpAsyncService(
                HttpServerNio.DEFAULT_HTTP_PROC, registry) {

            @Override
            public void connected(final NHttpServerConnection conn) {
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

                throw new OoopsieRuntimeException();
            }

        };

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(requestHandler));
        final HttpAsyncService serviceHandler = new HttpAsyncService(
                HttpServerNio.DEFAULT_HTTP_PROC, registry) {

                    @Override
                    public void exception(
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

                return false;
            }

        };

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(requestHandler));
        final HttpAsyncService serviceHandler = new HttpAsyncService(
                HttpServerNio.DEFAULT_HTTP_PROC, registry) {

            @Override
            public void exception(
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

                return true;
            }

        };

        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(requestHandler));
        final HttpAsyncService serviceHandler = new HttpAsyncService(
                HttpServerNio.DEFAULT_HTTP_PROC, registry) {

            @Override
            public void exception(
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

                new ResponseServer(),
                new ResponseContent(),
                new ResponseConnControl()
        });
        final HttpAsyncService serviceHandler = new HttpAsyncService(httpproc,
                new UriHttpAsyncRequestHandlerMapper());
        return new DefaultHttpServerIODispatch(serviceHandler, ConnectionConfig.DEFAULT);
    }
View Full Code Here

Examples of org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper

        return buffer.toString();
    }

    @Test
    public void testHttpGets() throws Exception {
        final UriHttpAsyncRequestHandlerMapper registry = new UriHttpAsyncRequestHandlerMapper();
        registry.register("*", new BasicAsyncRequestHandler(new SimpleRequestHandler()));
        final InetSocketAddress address = start(registry, null);

        this.client.setMaxPerRoute(3);
        this.client.setMaxTotal(3);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.