Examples of PipeImpl


Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

        // allocate temporary buffers to process this request
        context.setAttribute(REQUEST_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
        context.setAttribute(RESPONSE_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));

        try {
            PipeImpl requestPipe  = new PipeImpl(); // the pipe used to process the request
            PipeImpl responsePipe = new PipeImpl(); // the pipe used to process the response
            context.setAttribute(REQUEST_SINK_CHANNEL, requestPipe.sink());
            context.setAttribute(RESPONSE_SOURCE_CHANNEL, responsePipe.source());

            // create the default response to this request
            ProtocolVersion httpVersion = request.getRequestLine().getProtocolVersion();
            HttpResponse response = responseFactory.newHttpResponse(
                httpVersion, HttpStatus.SC_OK, context);
            response.setParams(this.params);

            // create a basic HttpEntity using the source channel of the response pipe
            BasicHttpEntity entity = new BasicHttpEntity();
            entity.setContent(Channels.newInputStream(responsePipe.source()));
            if (httpVersion.greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);

            // hand off processing of the request to a thread off the pool
            workerPool.execute(
                new ServerWorker(cfgCtx, conn, isHttps, this,
                    request, Channels.newInputStream(requestPipe.source()),
                    response, Channels.newOutputStream(responsePipe.sink())));

        } catch (IOException e) {
            handleException("Error processing request received for : " +
                request.getRequestLine().getUri(), e, conn);
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
        } catch (AxisFault axisFault) {
            log.error("Cannot find a suitable MessageFormatter : " + axisFault.getMessage());
        }
        try {
            this.pipe = new PipeImpl();
        } catch (IOException e) {
            log.error("Error creating pipe to write message body");
        }
    }
View Full Code Here

Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

     * @param response
     */
    private void processResponse(final NHttpClientConnection conn, HttpContext context, HttpResponse response) {

        try {
            PipeImpl responsePipe = new PipeImpl();
            context.setAttribute(RESPONSE_SINK_CHANNEL, responsePipe.sink());

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);

            workerPool.execute(
                new ClientWorker(cfgCtx, Channels.newInputStream(responsePipe.source()), response,
                    (MessageContext) context.getAttribute(OUTGOING_MESSAGE_CONTEXT)));

        } catch (IOException e) {
            handleException("I/O Error : " + e.getMessage(), e, conn);
        }
View Full Code Here

Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

     * @param response
     */
    private void processResponse(final NHttpClientConnection conn, HttpContext context, HttpResponse response) {

        try {
            PipeImpl responsePipe = new PipeImpl();
            context.setAttribute(RESPONSE_SINK_CHANNEL, responsePipe.sink());

            BasicHttpEntity entity = new BasicHttpEntity();
            if (response.getStatusLine().getProtocolVersion().greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);

            workerPool.execute(
                new ClientWorker(cfgCtx, Channels.newInputStream(responsePipe.source()), response,
                    (MessageContext) context.getAttribute(OUTGOING_MESSAGE_CONTEXT)));

        } catch (IOException e) {
            handleException("I/O Error : " + e.getMessage(), e, conn);
        }
View Full Code Here

Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

            messageFormatter = TransportUtils.getMessageFormatter(msgContext);
        } catch (AxisFault axisFault) {
            log.error("Cannot find a suitable MessageFormatter : " + axisFault.getMessage());
        }
        try {
            this.pipe = new PipeImpl();
        } catch (IOException e) {
            log.error("Error creating pipe to write message body", e);
        }
    }
View Full Code Here

Examples of org.apache.synapse.transport.nhttp.util.PipeImpl

        // allocate temporary buffers to process this request
        context.setAttribute(REQUEST_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));
        context.setAttribute(RESPONSE_BUFFER, ByteBuffer.allocate(cfg.getBufferZise()));

        try {
            PipeImpl requestPipe  = new PipeImpl(); // the pipe used to process the request
            PipeImpl responsePipe = new PipeImpl(); // the pipe used to process the response
            context.setAttribute(REQUEST_SINK_CHANNEL, requestPipe.sink());
            context.setAttribute(RESPONSE_SOURCE_CHANNEL, responsePipe.source());

            // create the default response to this request
            ProtocolVersion httpVersion = request.getRequestLine().getProtocolVersion();
            HttpResponse response = responseFactory.newHttpResponse(
                httpVersion, HttpStatus.SC_OK, context);
            response.setParams(this.params);

            // create a basic HttpEntity using the source channel of the response pipe
            BasicHttpEntity entity = new BasicHttpEntity();
            entity.setContent(Channels.newInputStream(responsePipe.source()));
            if (httpVersion.greaterEquals(HttpVersion.HTTP_1_1)) {
                entity.setChunked(true);
            }
            response.setEntity(entity);

            // hand off processing of the request to a thread off the pool
            workerPool.execute(
                new ServerWorker(cfgCtx, conn, isHttps, metrics, this,
                    request, Channels.newInputStream(requestPipe.source()),
                    response, Channels.newOutputStream(responsePipe.sink())));

        } catch (IOException e) {
            handleException("Error processing request received for : " +
                request.getRequestLine().getUri(), e, conn);
            if (metrics != null) {
View Full Code Here

Examples of org.gbcpainter.game.model.grid.PipeImpl

    }
  }

  @Test
  public void testPipeColoring() throws Exception {
    Pipe pipe = new PipeImpl( new ImmutableSegment2D( 0, 0, 0, 10 ) );

    assertFalse( pipe.isColored() );
    pipe.setColored( new Point( 0, 1 ), true );

    assertFalse( pipe.isColored() );
    assertTrue( pipe.isColoredAt( new Point( 0, 1 ) ) );

    for (int i = 1; i < 4; i++) {
      pipe.setColored( new Point( 0, i ), true );
    }

    try {
      pipe.setColored( new Point( 88, 55 ), true );
      fail();
    } catch ( IllegalArgumentException e ) {
    }

    try {
      pipe.setColored( new Point( 0, 0 ), true );
      fail();
    } catch ( IllegalArgumentException e ) {
    }

    try {
      pipe.setColored( new Point( 0, 10 ), true );
      fail();
    } catch ( IllegalArgumentException e ) {
    }

    assertFalse( pipe.isColored() );
    assertTrue( pipe.isColoredAt( new Point( 0, 3 ) ) );
    assertFalse( pipe.isColoredAt( new Point( 0, 4 ) ) );

    pipe.setColored( new Point( 0, 1 ), false );
    assertFalse( pipe.isColoredAt( new Point( 0, 1 ) ) );
    assertTrue( pipe.isColoredAt( new Point( 0, 2 ) ) );

    pipe.reset();
    assertFalse( pipe.isColoredAt( new Point( 0, 2 ) ) );


    for (int i = 1; i < 10; i++) {
      pipe.setColored( new Point( 0, i ), true );
    }
    assertTrue( pipe.isColored() );

    pipe.reset();
    assertFalse( pipe.isColored() );

    for (int i = 1; i < 4; i++) {
      pipe.setColored( new Point( 0, i ), true );
    }

    for (int i = 9; i > 4; i--) {
      pipe.setColored( new Point( 0, i ), true );
    }

    assertFalse( pipe.isColored() );

    pipe.setColored( new Point( 0, 4 ), true );

    assertTrue( pipe.isColored() );
  }
View Full Code Here

Examples of org.gbcpainter.game.model.grid.PipeImpl

    assertFalse( junction.isColored() );
  }

  @Test
  public void pipeHitTest() throws Exception {
    Pipe pipe = new PipeImpl( new ImmutableSegment2D( 0, 0, 0, 10 ) );

    assertTrue( pipe.contains( new Point( 0, 1 ) ) );
    assertFalse( pipe.contains( new Point( 0, 0 ) ) );
    assertFalse( pipe.contains( new Point( 0, 10 ) ) );

    assertFalse( pipe.contains( new Point( 1, 0 ) ) );
    assertFalse( pipe.contains( new Point( - 1, 0 ) ) );

    assertEquals( pipe.getAvailableDirections(), new HashSet<>( Arrays.asList( PERPENDICULAR_DIRECTION.UP, PERPENDICULAR_DIRECTION.DOWN ) ) );
  }
View Full Code Here

Examples of org.gbcpainter.game.model.grid.PipeImpl

  @NotNull
  @Override
  public Pipe createEdge( @NotNull final Segment segment ) throws IllegalArgumentException {
    try {
      return new PipeImpl( segment );
    } catch ( Exception e ) {
      throw new IllegalArgumentException( e );
    }
  }
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.