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

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

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

Util.readGenericStreamable介绍

暂无

代码示例

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

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

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

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

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

  1. public void readFrom(DataInput in) throws Exception {
  2. type=Type.values()[in.readByte()];
  3. // We can't use Util.readObject since it's size is limited to 2^15-1
  4. try {
  5. short first = in.readShort();
  6. if (first == -1) {
  7. object = Util.readGenericStreamable(in);
  8. }
  9. else {
  10. ByteBuffer bb = ByteBuffer.allocate(4);
  11. bb.putShort(first);
  12. bb.putShort(in.readShort());
  13. int size = bb.getInt(0);
  14. byte[] bytes = new byte[size];
  15. in.readFully(bytes, 0, size);
  16. object = Util.objectFromByteBuffer(bytes);
  17. }
  18. }
  19. catch (IOException e) {
  20. throw e;
  21. }
  22. catch (Exception e) {
  23. throw new IOException("Exception encountered while serializing execution request", e);
  24. }
  25. request=in.readLong();
  26. }

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

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

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

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

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

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

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

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

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

  1. public static Object readObject(DataInputStream in) throws Exception {
  2. short len=in.readShort();
  3. Object retval=null;
  4. if(len == -1) {
  5. retval=readGenericStreamable(in);
  6. }
  7. else {
  8. byte[] buf=new byte[len];
  9. in.readFully(buf, 0, len);
  10. retval=objectFromByteBuffer(buf);
  11. }
  12. return retval;
  13. }

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

  1. public static Object oldObjectFromByteBuffer(byte[] buffer, int offset, int length) throws Exception {
  2. if(buffer == null) return null;
  3. Object retval=null;
  4. try { // to read the object as an Externalizable
  5. ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer, offset, length);
  6. ObjectInputStream in=new ContextObjectInputStream(in_stream); // changed Nov 29 2004 (bela)
  7. retval=in.readObject();
  8. in.close();
  9. }
  10. catch(StreamCorruptedException sce) {
  11. try { // is it Streamable?
  12. ByteArrayInputStream in_stream=new ByteArrayInputStream(buffer, offset, length);
  13. DataInputStream in=new DataInputStream(in_stream);
  14. retval=readGenericStreamable(in);
  15. in.close();
  16. }
  17. catch(Exception ee) {
  18. IOException tmp=new IOException("unmarshalling failed");
  19. tmp.initCause(ee);
  20. throw tmp;
  21. }
  22. }
  23. if(retval == null)
  24. return null;
  25. return retval;
  26. }

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

  1. public void readFrom(DataInput in) throws Exception {
  2. type=Type.values()[in.readByte()];
  3. // We can't use Util.readObject since it's size is limited to 2^15-1
  4. try {
  5. short first = in.readShort();
  6. if (first == -1) {
  7. object = Util.readGenericStreamable(in);
  8. }
  9. else {
  10. ByteBuffer bb = ByteBuffer.allocate(4);
  11. bb.putShort(first);
  12. bb.putShort(in.readShort());
  13. int size = bb.getInt(0);
  14. byte[] bytes = new byte[size];
  15. in.readFully(bytes, 0, size);
  16. object = Util.objectFromByteBuffer(bytes);
  17. }
  18. }
  19. catch (IOException e) {
  20. throw e;
  21. }
  22. catch (Exception e) {
  23. throw new IOException("Exception encountered while serializing execution request", e);
  24. }
  25. request=in.readLong();
  26. }

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

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

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

  1. case TYPE_STREAMABLE:
  2. in=new DataInputStream(in_stream);
  3. retval=readGenericStreamable((DataInputStream)in);
  4. break;
  5. case TYPE_SERIALIZABLE: // the object is Externalizable or Serializable

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

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

相关文章

Util类方法