org.jgroups.util.Util.readGenericStreamable()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.jgroups.util.Util.readGenericStreamable()方法的一些代码示例,展示了Util.readGenericStreamable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.readGenericStreamable()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:readGenericStreamable

Util.readGenericStreamable介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static <T extends Streamable> T readGenericStreamable(DataInput in) throws Exception {
  return readGenericStreamable(in, null);
}

代码示例来源:origin: wildfly/wildfly

public static Object readObject(DataInput in) throws Exception {
  int len=in.readInt();
  if(len == -1)
    return readGenericStreamable(in);
  byte[] buf=new byte[len];
  in.readFully(buf, 0, len);
  return objectFromByteBuffer(buf);
}

代码示例来源:origin: wildfly/wildfly

public void readFrom(DataInput in) throws Exception {
  type=Type.values()[in.readByte()];
  // We can't use Util.readObject since it's size is limited to 2^15-1
  try {
    short first = in.readShort();
    if (first == -1) {
      object = Util.readGenericStreamable(in);
    }
    else {
      ByteBuffer bb = ByteBuffer.allocate(4);
      bb.putShort(first);
      bb.putShort(in.readShort());
      
      int size = bb.getInt(0);
      byte[] bytes = new byte[size];
      in.readFully(bytes, 0, size);
      object = Util.objectFromByteBuffer(bytes);
    }
  }
  catch (IOException e) {
    throw e;
  }
  catch (Exception e) {
    throw new IOException("Exception encountered while serializing execution request", e);
  }
  request=in.readLong();
}

代码示例来源:origin: wildfly/wildfly

case TYPE_STREAMABLE: return readGenericStreamable(in, loader);
case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable
  InputStream is=in instanceof ByteArrayDataInputStream?

代码示例来源:origin: wildfly/wildfly

case TYPE_STREAMABLE:
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  return readGenericStreamable(in, loader);
case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable
  InputStream in_stream=new ByteArrayInputStream(buffer,offset,length);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static <T extends Streamable> T readGenericStreamable(DataInput in) throws Exception {
  return readGenericStreamable(in, null);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static Object readObject(DataInput in) throws Exception {
  int len=in.readInt();
  if(len == -1)
    return readGenericStreamable(in);
  byte[] buf=new byte[len];
  in.readFully(buf, 0, len);
  return objectFromByteBuffer(buf);
}

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

public static Object readObject(DataInputStream in) throws Exception {
  short len=in.readShort();
  Object retval=null;
  if(len == -1) {
    retval=readGenericStreamable(in);
  }
  else {
    byte[] buf=new byte[len];
    in.readFully(buf, 0, len);
    retval=objectFromByteBuffer(buf);
  }
  return retval;
}

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

public static Object oldObjectFromByteBuffer(byte[] buffer, int offset, int length) throws Exception {
  if(buffer == null) return null;
  Object retval=null;
  try {  // to read the object as an Externalizable
    ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer, offset, length);
    ObjectInputStream in=new ContextObjectInputStream(in_stream); // changed Nov 29 2004 (bela)
    retval=in.readObject();
    in.close();
  }
  catch(StreamCorruptedException sce) {
    try {  // is it Streamable?
      ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer, offset, length);
      DataInputStream in=new DataInputStream(in_stream);
      retval=readGenericStreamable(in);
      in.close();
    }
    catch(Exception ee) {
      IOException tmp=new IOException("unmarshalling failed");
      tmp.initCause(ee);
      throw tmp;
    }
  }
  if(retval == null)
    return null;
  return retval;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public void readFrom(DataInput in) throws Exception {
  type=Type.values()[in.readByte()];
  // We can't use Util.readObject since it's size is limited to 2^15-1
  try {
    short first = in.readShort();
    if (first == -1) {
      object = Util.readGenericStreamable(in);
    }
    else {
      ByteBuffer bb = ByteBuffer.allocate(4);
      bb.putShort(first);
      bb.putShort(in.readShort());
      
      int size = bb.getInt(0);
      byte[] bytes = new byte[size];
      in.readFully(bytes, 0, size);
      object = Util.objectFromByteBuffer(bytes);
    }
  }
  catch (IOException e) {
    throw e;
  }
  catch (Exception e) {
    throw new IOException("Exception encountered while serializing execution request", e);
  }
  request=in.readLong();
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

case TYPE_STREAMABLE: return readGenericStreamable(in, loader);
case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable
  InputStream is=in instanceof ByteArrayDataInputStream?

代码示例来源:origin: org.jgroups/com.springsource.org.jgroups

case TYPE_STREAMABLE:
  in=new DataInputStream(in_stream);
  retval=readGenericStreamable((DataInputStream)in);
  break;
case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable

代码示例来源:origin: org.jboss.eap/wildfly-client-all

case TYPE_STREAMABLE:
  DataInput in=new ByteArrayDataInputStream(buffer,offset,length);
  return readGenericStreamable(in, loader);
case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable
  InputStream in_stream=new ByteArrayInputStream(buffer,offset,length);

相关文章

微信公众号

最新文章

更多

Util类方法