Package com.facebook.thrift.transport

Examples of com.facebook.thrift.transport.TIOStreamTransport


  protected TIOStreamTransport outTransport, inTransport;
  protected TProtocol outProtocol, inProtocol;

  private void init(TProtocolFactory inFactory, TProtocolFactory outFactory) throws Exception {
    outTransport = new TIOStreamTransport(bos);
    inTransport = new TIOStreamTransport(bis);
    outProtocol = outFactory.getProtocol(outTransport);
    inProtocol = inFactory.getProtocol(inTransport);
  }
View Full Code Here


  public final static int ITERATIONS = 100000;

    public MediaContent deserialize(byte[] array) throws Exception
  {
    ByteArrayInputStream bais = new ByteArrayInputStream(array);
    TIOStreamTransport trans = new TIOStreamTransport(bais);
    TBinaryProtocol oprot = new TBinaryProtocol(trans);
    MediaContent content = new MediaContent();
    content.read(oprot);
    return content;
  }
View Full Code Here

  }

    public byte[] serialize(MediaContent content) throws Exception
  {
      ByteArrayOutputStream baos = new ByteArrayOutputStream(expectedSize);
    TIOStreamTransport trans = new TIOStreamTransport(baos);
    TBinaryProtocol oprot = new TBinaryProtocol(trans);
    content.write(oprot);
    byte[] array = baos.toByteArray();
    expectedSize = array.length;
    return array;
View Full Code Here

    if (args.length != 2) {
      System.out.println("usage: java -cp build/classes com.facebook.thrift.test.WriteStruct filename proto_factory_class");
      System.out.println("Write out an instance of Fixtures.compactProtocolTestStruct to 'file'. Use a protocol from 'proto_factory_class'.");
    }

    TTransport trans = new TIOStreamTransport(new BufferedOutputStream(new FileOutputStream(args[0])));

    TProtocolFactory factory = (TProtocolFactory)Class.forName(args[1]).newInstance();

    TProtocol proto = factory.getProtocol(trans);

    Fixtures.compactProtoTestStruct.write(proto);
    trans.flush();
  }
View Full Code Here

  /**
   * Write struct to JSON, using given protocol.
   */
  private static String write(TProtocolFactory protocolFactory, TBase s) throws Exception {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    TIOStreamTransport transport = new TIOStreamTransport(null, outputStream);
    TProtocol protocol = protocolFactory.getProtocol(transport);
    s.write(protocol);
    String utf8Encoding = outputStream.toString("UTF-8");
    return utf8Encoding;
  }
View Full Code Here

   * @param bytes The array to read from
   */
  public void deserialize(TBase base, byte[] bytes) throws TException {
    base.read(
        protocolFactory_.getProtocol(
          new TIOStreamTransport(
            new ByteArrayInputStream(bytes))));
  }
View Full Code Here

   */
  private static void read(TProtocolFactory protocolFactory, String string, TBase s)
    throws Exception {
    byte[] byteEncoding = string.getBytes("UTF-8");
    ByteArrayInputStream inputStream = new ByteArrayInputStream(byteEncoding);
    TIOStreamTransport transport = new TIOStreamTransport(inputStream, null);
    TProtocol protocol = protocolFactory.getProtocol(transport);
    s.read(protocol);
  }
View Full Code Here

        }
      }
      InputStream in = request.getInputStream();
      OutputStream out = response.getOutputStream();

      TTransport transport = new TIOStreamTransport(in, out);
      inTransport = transport;
      outTransport = transport;

      TProtocol inProtocol = inProtocolFactory.getProtocol(inTransport);
      TProtocol outProtocol = outProtocolFactory.getProtocol(outTransport);
View Full Code Here

    if (args.length != 2) {
      System.out.println("usage: java -cp build/classes com.facebook.thrift.test.ReadStruct filename proto_factory_class");
      System.out.println("Read in an instance of CompactProtocolTestStruct from 'file', making sure that it is equivalent to Fixtures.compactProtoTestStruct. Use a protocol from 'proto_factory_class'.");
    }

    TTransport trans = new TIOStreamTransport(new BufferedInputStream(new FileInputStream(args[0])));

    TProtocolFactory factory = (TProtocolFactory)Class.forName(args[1]).newInstance();

    TProtocol proto = factory.getProtocol(trans);
View Full Code Here

    /**
     * Wrap the read buffer in a memory-based transport so a processor can read
     * the data it needs to handle an invocation.
     */
    public synchronized TTransport getInputTransport() {
      return inputTransportFactory_.getTransport(new TIOStreamTransport(
          new ByteArrayInputStream(buffer_.array())));
    }
View Full Code Here

TOP

Related Classes of com.facebook.thrift.transport.TIOStreamTransport

Copyright © 2018 www.massapicom. 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.