org.jgroups.Message.createHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(171)

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

Message.createHeaders介绍

暂无

代码示例

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

  1. public Message(boolean create_headers) {
  2. if(create_headers)
  3. headers=createHeaders(Util.DEFAULT_HEADERS);
  4. }

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

  1. /**
  2. * Constructs a message given a destination address
  3. * @param dest The Address of the receiver. If it is null, then the message is sent to the group. Otherwise, it is
  4. * sent to a single member.
  5. */
  6. public Message(Address dest) {
  7. setDest(dest);
  8. headers=createHeaders(Util.DEFAULT_HEADERS);
  9. }

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

  1. public void readFrom(DataInput in) throws Exception {
  2. // 1. read the leading byte first
  3. byte leading=in.readByte();
  4. // 2. the flags
  5. flags=in.readShort();
  6. // 3. dest_addr
  7. if(Util.isFlagSet(leading, DEST_SET))
  8. dest_addr=Util.readAddress(in);
  9. // 4. src_addr
  10. if(Util.isFlagSet(leading, SRC_SET))
  11. src_addr=Util.readAddress(in);
  12. // 5. headers
  13. int len=in.readShort();
  14. this.headers=createHeaders(len);
  15. for(int i=0; i < len; i++) {
  16. short id=in.readShort();
  17. Header hdr=readHeader(in).setProtId(id);
  18. this.headers[i]=hdr;
  19. }
  20. // 6. buf
  21. if(Util.isFlagSet(leading, BUF_SET)) {
  22. len=in.readInt();
  23. buf=new byte[len];
  24. in.readFully(buf, 0, len);
  25. length=len;
  26. }
  27. }

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

  1. /**
  2. * Create a copy of the message. If offset and length are used (to refer to another buffer), the
  3. * copy will contain only the subset offset and length point to, copying the subset into the new
  4. * copy.<p/>
  5. * Note that for headers, only the arrays holding references to the headers are copied, not the headers themselves !
  6. * The consequence is that the headers array of the copy hold the *same* references as the original, so do *not*
  7. * modify the headers ! If you want to change a header, copy it and call {@link Message#putHeader(short,Header)} again.
  8. *
  9. * @param copy_buffer
  10. * @param copy_headers
  11. * Copy the headers
  12. * @return Message with specified data
  13. */
  14. public Message copy(boolean copy_buffer, boolean copy_headers) {
  15. Message retval=new Message(false);
  16. retval.dest_addr=dest_addr;
  17. retval.src_addr=src_addr;
  18. short tmp_flags=this.flags;
  19. byte tmp_tflags=this.transient_flags;
  20. retval.flags=tmp_flags;
  21. retval.transient_flags=tmp_tflags;
  22. if(copy_buffer && buf != null)
  23. retval.setBuffer(buf, offset, length);
  24. //noinspection NonAtomicOperationOnVolatileField
  25. retval.headers=copy_headers && headers != null? Headers.copy(this.headers) : createHeaders(Util.DEFAULT_HEADERS);
  26. return retval;
  27. }

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

  1. /** Reads the message's contents from an input stream, but skips the buffer and instead returns the
  2. * position (offset) at which the buffer starts */
  3. public int readFromSkipPayload(ByteArrayDataInputStream in) throws Exception {
  4. // 1. read the leading byte first
  5. byte leading=in.readByte();
  6. // 2. the flags
  7. flags=in.readShort();
  8. // 3. dest_addr
  9. if(Util.isFlagSet(leading, DEST_SET))
  10. dest_addr=Util.readAddress(in);
  11. // 4. src_addr
  12. if(Util.isFlagSet(leading, SRC_SET))
  13. src_addr=Util.readAddress(in);
  14. // 5. headers
  15. int len=in.readShort();
  16. headers=createHeaders(len);
  17. for(int i=0; i < len; i++) {
  18. short id=in.readShort();
  19. Header hdr=readHeader(in).setProtId(id);
  20. this.headers[i]=hdr;
  21. }
  22. // 6. buf
  23. if(!Util.isFlagSet(leading, BUF_SET))
  24. return -1;
  25. length=in.readInt();
  26. return in.position();
  27. }

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

  1. public Message(boolean create_headers) {
  2. if(create_headers)
  3. headers=createHeaders(7);
  4. }

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

  1. public Message(boolean create_headers) {
  2. if(create_headers)
  3. headers=createHeaders(Util.DEFAULT_HEADERS);
  4. }

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

  1. public Message() {
  2. headers=createHeaders(7);
  3. }

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

  1. /** Public constructor
  2. * @param dest Address of receiver. If it is <em>null</em> then the message sent to the group.
  3. * Otherwise, it contains a single destination and is sent to that member.<p>
  4. */
  5. public Message(Address dest) {
  6. setDest(dest);
  7. headers=createHeaders(7);
  8. }

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

  1. /**
  2. * Constructs a message given a destination address
  3. * @param dest The Address of the receiver. If it is null, then the message is sent to the group. Otherwise, it is
  4. * sent to a single member.
  5. */
  6. public Message(Address dest) {
  7. setDest(dest);
  8. headers=createHeaders(Util.DEFAULT_HEADERS);
  9. }

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

  1. /**
  2. * Create a copy of the message. If offset and length are used (to refer to another buffer), the copy will
  3. * contain only the subset offset and length point to, copying the subset into the new copy.
  4. * @param copy_buffer
  5. * @return Message with specified data
  6. */
  7. public Message copy(boolean copy_buffer) {
  8. Message retval=new Message(false);
  9. retval.dest_addr=dest_addr;
  10. retval.src_addr=src_addr;
  11. retval.flags=flags;
  12. if(copy_buffer && buf != null) {
  13. // change bela Feb 26 2004: we don't resolve the reference
  14. retval.setBuffer(buf, offset, length);
  15. }
  16. header_lock.readLock().lock();
  17. try {
  18. retval.headers=createHeaders(headers);
  19. }
  20. finally {
  21. header_lock.readLock().unlock();
  22. }
  23. return retval;
  24. }

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

  1. headers=createHeaders(len);
  2. for(int i=0; i < len; i++) {
  3. hdr_name=in.readUTF();

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

  1. public void readFrom(DataInput in) throws Exception {
  2. // 1. read the leading byte first
  3. byte leading=in.readByte();
  4. // 2. the flags
  5. flags=in.readShort();
  6. // 3. dest_addr
  7. if(Util.isFlagSet(leading, DEST_SET))
  8. dest_addr=Util.readAddress(in);
  9. // 4. src_addr
  10. if(Util.isFlagSet(leading, SRC_SET))
  11. src_addr=Util.readAddress(in);
  12. // 5. headers
  13. int len=in.readShort();
  14. this.headers=createHeaders(len);
  15. for(int i=0; i < len; i++) {
  16. short id=in.readShort();
  17. Header hdr=readHeader(in).setProtId(id);
  18. this.headers[i]=hdr;
  19. }
  20. // 6. buf
  21. if(Util.isFlagSet(leading, BUF_SET)) {
  22. len=in.readInt();
  23. buf=new byte[len];
  24. in.readFully(buf, 0, len);
  25. length=len;
  26. }
  27. }

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

  1. /**
  2. * Create a copy of the message. If offset and length are used (to refer to another buffer), the
  3. * copy will contain only the subset offset and length point to, copying the subset into the new
  4. * copy.<p/>
  5. * Note that for headers, only the arrays holding references to the headers are copied, not the headers themselves !
  6. * The consequence is that the headers array of the copy hold the *same* references as the original, so do *not*
  7. * modify the headers ! If you want to change a header, copy it and call {@link Message#putHeader(short,Header)} again.
  8. *
  9. * @param copy_buffer
  10. * @param copy_headers
  11. * Copy the headers
  12. * @return Message with specified data
  13. */
  14. public Message copy(boolean copy_buffer, boolean copy_headers) {
  15. Message retval=new Message(false);
  16. retval.dest_addr=dest_addr;
  17. retval.src_addr=src_addr;
  18. short tmp_flags=this.flags;
  19. byte tmp_tflags=this.transient_flags;
  20. retval.flags=tmp_flags;
  21. retval.transient_flags=tmp_tflags;
  22. if(copy_buffer && buf != null)
  23. retval.setBuffer(buf, offset, length);
  24. //noinspection NonAtomicOperationOnVolatileField
  25. retval.headers=copy_headers && headers != null? Headers.copy(this.headers) : createHeaders(Util.DEFAULT_HEADERS);
  26. return retval;
  27. }

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

  1. /** Reads the message's contents from an input stream, but skips the buffer and instead returns the
  2. * position (offset) at which the buffer starts */
  3. public int readFromSkipPayload(ByteArrayDataInputStream in) throws Exception {
  4. // 1. read the leading byte first
  5. byte leading=in.readByte();
  6. // 2. the flags
  7. flags=in.readShort();
  8. // 3. dest_addr
  9. if(Util.isFlagSet(leading, DEST_SET))
  10. dest_addr=Util.readAddress(in);
  11. // 4. src_addr
  12. if(Util.isFlagSet(leading, SRC_SET))
  13. src_addr=Util.readAddress(in);
  14. // 5. headers
  15. int len=in.readShort();
  16. headers=createHeaders(len);
  17. for(int i=0; i < len; i++) {
  18. short id=in.readShort();
  19. Header hdr=readHeader(in).setProtId(id);
  20. this.headers[i]=hdr;
  21. }
  22. // 6. buf
  23. if(!Util.isFlagSet(leading, BUF_SET))
  24. return -1;
  25. length=in.readInt();
  26. return in.position();
  27. }

相关文章