Examples of asInputStream()


Examples of org.apache.mina.common.ByteBuffer.asInputStream()

          final ServletOutputStream out = resp.getOutputStream();
          ByteBuffer buf = (ByteBuffer) message;
          resp.setStatus(HttpServletResponse.SC_OK);
          resp.setContentType(req.getContentType());
          resp.setContentLength(buf.limit());
          ServletUtils.copy(buf.asInputStream(), out);
          out.flush();
          out.close();
        } catch (IOException e) {
          log.error("Error sending response", e);
        }
View Full Code Here

Examples of org.apache.mina.common.ByteBuffer.asInputStream()

  public Object invokeMethod(String method, Object[] params) {
    PostMethod post = new PostMethod(this.url + appendToUrl);
    ByteBuffer resultBuffer = null;
    ByteBuffer data = encodeInvoke(method, params);
    post.setRequestEntity(new InputStreamRequestEntity(
        data.asInputStream(), data.limit(), CONTENT_TYPE));
    try {
      int resultCode = client.executeMethod(post);
      if (resultCode / 100 != 2) {
        throw new RuntimeException(
            "Didn't receive success from remoting server.");
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

    //setup POST
    HttpPost post = null;
    try {
      post = new HttpPost(url + appendToUrl);
      post.addHeader("Content-Type", CONTENT_TYPE);
      post.setEntity(new InputStreamEntity(data.asInputStream(), data.limit()));
      // execute the method
      HttpResponse response = client.execute(post);
      int code = response.getStatusLine().getStatusCode();
      log.debug("HTTP response code: {}", code);
      if (code / 100 != 2) {
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

        out.writeString(object.getClass().getName());
        object.serialize(out);
        buf.flip();

        FileOutputStream output = new FileOutputStream(file.getAbsolutePath());
        ServletUtils.copy(buf.asInputStream(), output);
        output.close();
        log.debug("Stored persistent object {} at {}", object, filename);
      } catch (IOException e) {
        log.error("Could not create / write file {}", filename, e);
        log.warn("Exception {}", e);
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

      if (reqContentLength > 0) {
        log.debug("Request content length: {}", reqContentLength);
        IoBuffer reqBuffer = IoBuffer.allocate(reqContentLength);
        ServletUtils.copy(req, reqBuffer.asOutputStream());
        reqBuffer.flip();
        post.setEntity(new InputStreamEntity(reqBuffer.asInputStream(), reqContentLength));
        post.addHeader("Content-Type", REQUEST_TYPE);
        // get.setPath(path);
        post.addHeader("Tunnel-request", path);
        // execute the method
        HttpResponse response = client.execute(post);
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

            resp.setContentType(REQUEST_TYPE);
            // get the response as bytes
            byte[] bytes = EntityUtils.toByteArray(entity);
            IoBuffer resultBuffer = IoBuffer.wrap(bytes);
            resultBuffer.flip();
            ServletUtils.copy(resultBuffer.asInputStream(), resp.getOutputStream());
            resp.flushBuffer();
          }
        } else {
          resp.sendError(code);
        }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

    log.debug("Sending response");
    IoBuffer respBuffer = codecFactory.getRemotingEncoder().encode(packet);
    if (respBuffer != null) {
      final ServletOutputStream out = resp.getOutputStream();
      resp.setContentLength(respBuffer.limit());
      ServletUtils.copy(respBuffer.asInputStream(), out);
      out.flush();
      out.close();
      respBuffer.free();
      respBuffer = null;
    } else {
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer.asInputStream()

        } else if (message instanceof IoBuffer) {
            SoapTcpSessionState sessionState = (SoapTcpSessionState)session.getAttribute("sessionState");
            if (sessionState != null
                && sessionState.getStateId() == SoapTcpSessionState.SOAP_TCP_SESSION_STATE_NEW) {
                IoBuffer buffer = (IoBuffer) message;
                InputStream inStream = buffer.asInputStream();
                byte magicIdBuffer[] = new byte[MAGIC_IDENTIFIER.length()];
                inStream.read(magicIdBuffer);
                String magicId = new String(magicIdBuffer, "US-ASCII");
                if (magicId.equals(MAGIC_IDENTIFIER)) {
                    int version[] = new int[4];
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.