1 24 package org.objectweb.joram.shared.client; 25 26 import java.io.Externalizable ; 27 import java.io.InputStream ; 28 import java.io.OutputStream ; 29 import java.io.IOException ; 30 import java.util.Enumeration ; 31 import java.util.Vector ; 32 33 import org.objectweb.joram.shared.messages.Message; 34 import org.objectweb.joram.shared.stream.Streamable; 35 import org.objectweb.joram.shared.stream.StreamUtil; 36 37 41 public final class ProducerMessages extends AbstractJmsRequest { 42 43 private Vector messages = null; 44 45 50 private boolean asyncSend = false; 51 52 public void setAsyncSend(boolean b) { 53 asyncSend = b; 54 } 55 56 public final boolean getAsyncSend() { 57 return asyncSend; 58 } 59 60 61 public Vector getMessages() { 62 if (messages == null) 63 messages = new Vector (); 64 return messages; 65 } 66 67 68 public void addMessage(Message msg) { 69 if (messages == null) 70 messages = new Vector (); 71 messages.addElement(msg); 72 } 73 74 75 public void addMessages(Vector msgs) { 76 if (messages == null) 77 messages = new Vector (); 78 for (Enumeration e = msgs.elements(); e.hasMoreElements(); ) 79 messages.addElement(e.nextElement()); 80 } 81 82 protected int getClassId() { 83 return PRODUCER_MESSAGES; 84 } 85 86 91 public ProducerMessages(String dest) { 92 super(dest); 93 } 94 95 102 public ProducerMessages(String dest, Message msg) { 103 super(dest); 104 messages = new Vector (); 105 messages.addElement(msg); 106 } 107 108 111 public ProducerMessages() {} 112 113 public void toString(StringBuffer strbuf) { 114 super.toString(strbuf); 115 strbuf.append(",messages=").append(messages); 116 strbuf.append(",asyncSend=").append(asyncSend); 117 strbuf.append(')'); 118 } 119 120 123 124 130 public void writeTo(OutputStream os) throws IOException { 131 super.writeTo(os); 132 Message.writeVectorTo(messages, os); 133 StreamUtil.writeTo(asyncSend, os); 134 } 135 136 142 public void readFrom(InputStream is) throws IOException { 143 super.readFrom(is); 144 messages = Message.readVectorFrom(is); 145 asyncSend = StreamUtil.readBooleanFrom(is); 146 } 147 } 148 | Popular Tags |