Package org.apache.hadoop.hbase.stargate

Examples of org.apache.hadoop.hbase.stargate.ProtobufMessageHandler


  @Override
  public ProtobufMessageHandler readFrom(Class<ProtobufMessageHandler> type, Type genericType,
      Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders, InputStream inputStream)
      throws IOException, WebApplicationException {
    ProtobufMessageHandler obj = null;
    try {
      obj = type.newInstance();
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte[] buffer = new byte[4096];
      int read;
      do {
        read = inputStream.read(buffer, 0, buffer.length);
        if (read > 0) {
          baos.write(buffer, 0, read);
        }
      } while (read > 0);
      if (LOG.isDebugEnabled()) {
        LOG.debug(getClass() + ": read " + baos.size() + " bytes from " +
          inputStream);
      }
      obj = obj.getObjectFromMessage(baos.toByteArray());
    } catch (InstantiationException e) {
      throw new WebApplicationException(e);
    } catch (IllegalAccessException e) {
      throw new WebApplicationException(e);
    }
View Full Code Here


  @Override
  public ProtobufMessageHandler readFrom(Class<ProtobufMessageHandler> type, Type genericType,
      Annotation[] annotations, MediaType mediaType,
      MultivaluedMap<String, String> httpHeaders, InputStream inputStream)
      throws IOException, WebApplicationException {
    ProtobufMessageHandler obj = null;
    try {
      obj = type.newInstance();
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte[] buffer = new byte[4096];
      int read;
      do {
        read = inputStream.read(buffer, 0, buffer.length);
        if (read > 0) {
          baos.write(buffer, 0, read);
        }
      } while (read > 0);
      if (LOG.isDebugEnabled()) {
        LOG.debug(getClass() + ": read " + baos.size() + " bytes from " +
          inputStream);
      }
      obj = obj.getObjectFromMessage(baos.toByteArray());
    } catch (InstantiationException e) {
      throw new WebApplicationException(e);
    } catch (IllegalAccessException e) {
      throw new WebApplicationException(e);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.stargate.ProtobufMessageHandler

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.