001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.activemq.openwire.v2;
019
020 import java.io.DataInput;
021 import java.io.DataOutput;
022 import java.io.IOException;
023
024 import org.apache.activemq.command.DataStructure;
025 import org.apache.activemq.command.Message;
026 import org.apache.activemq.openwire.BooleanStream;
027 import org.apache.activemq.openwire.OpenWireFormat;
028
029 /**
030 * Marshalling code for Open Wire Format for MessageMarshaller NOTE!: This file
031 * is auto generated - do not modify! if you need to make a change, please see
032 * the modify the groovy scripts in the under src/gram/script and then use maven
033 * openwire:generate to regenerate this file.
034 *
035 *
036 */
037 public abstract class MessageMarshaller extends BaseCommandMarshaller {
038
039 /**
040 * Un-marshal an object instance from the data input stream
041 *
042 * @param o the object to un-marshal
043 * @param dataIn the data input stream to build the object from
044 * @throws IOException
045 */
046 public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {
047 super.tightUnmarshal(wireFormat, o, dataIn, bs);
048
049 Message info = (Message)o;
050
051 info.beforeUnmarshall(wireFormat);
052
053 info.setProducerId((org.apache.activemq.command.ProducerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
054 info.setDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
055 info.setTransactionId((org.apache.activemq.command.TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
056 info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
057 info.setMessageId((org.apache.activemq.command.MessageId)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
058 info.setOriginalTransactionId((org.apache.activemq.command.TransactionId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
059 info.setGroupID(tightUnmarshalString(dataIn, bs));
060 info.setGroupSequence(dataIn.readInt());
061 info.setCorrelationId(tightUnmarshalString(dataIn, bs));
062 info.setPersistent(bs.readBoolean());
063 info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));
064 info.setPriority(dataIn.readByte());
065 info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
066 info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
067 info.setType(tightUnmarshalString(dataIn, bs));
068 info.setContent(tightUnmarshalByteSequence(dataIn, bs));
069 info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
070 info.setDataStructure((org.apache.activemq.command.DataStructure)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
071 info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
072 info.setCompressed(bs.readBoolean());
073 info.setRedeliveryCounter(dataIn.readInt());
074
075 if (bs.readBoolean()) {
076 short size = dataIn.readShort();
077 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
078 for (int i = 0; i < size; i++) {
079 value[i] = (org.apache.activemq.command.BrokerId)tightUnmarsalNestedObject(wireFormat, dataIn, bs);
080 }
081 info.setBrokerPath(value);
082 } else {
083 info.setBrokerPath(null);
084 }
085 info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));
086 info.setUserID(tightUnmarshalString(dataIn, bs));
087 info.setRecievedByDFBridge(bs.readBoolean());
088 info.setDroppable(bs.readBoolean());
089
090 info.afterUnmarshall(wireFormat);
091
092 }
093
094 /**
095 * Write the booleans that this object uses to a BooleanStream
096 */
097 public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
098
099 Message info = (Message)o;
100
101 info.beforeMarshall(wireFormat);
102
103 int rc = super.tightMarshal1(wireFormat, o, bs);
104 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
105 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
106 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
107 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
108 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
109 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
110 rc += tightMarshalString1(info.getGroupID(), bs);
111 rc += tightMarshalString1(info.getCorrelationId(), bs);
112 bs.writeBoolean(info.isPersistent());
113 rc += tightMarshalLong1(wireFormat, info.getExpiration(), bs);
114 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
115 rc += tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
116 rc += tightMarshalString1(info.getType(), bs);
117 rc += tightMarshalByteSequence1(info.getContent(), bs);
118 rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
119 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
120 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
121 bs.writeBoolean(info.isCompressed());
122 rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
123 rc += tightMarshalLong1(wireFormat, info.getArrival(), bs);
124 rc += tightMarshalString1(info.getUserID(), bs);
125 bs.writeBoolean(info.isRecievedByDFBridge());
126 bs.writeBoolean(info.isDroppable());
127
128 return rc + 9;
129 }
130
131 /**
132 * Write a object instance to data output stream
133 *
134 * @param o the instance to be marshaled
135 * @param dataOut the output stream
136 * @throws IOException thrown if an error occurs
137 */
138 public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
139 super.tightMarshal2(wireFormat, o, dataOut, bs);
140
141 Message info = (Message)o;
142 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
143 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
144 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
145 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
146 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
147 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
148 tightMarshalString2(info.getGroupID(), dataOut, bs);
149 dataOut.writeInt(info.getGroupSequence());
150 tightMarshalString2(info.getCorrelationId(), dataOut, bs);
151 bs.readBoolean();
152 tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
153 dataOut.writeByte(info.getPriority());
154 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
155 tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
156 tightMarshalString2(info.getType(), dataOut, bs);
157 tightMarshalByteSequence2(info.getContent(), dataOut, bs);
158 tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
159 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
160 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
161 bs.readBoolean();
162 dataOut.writeInt(info.getRedeliveryCounter());
163 tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
164 tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
165 tightMarshalString2(info.getUserID(), dataOut, bs);
166 bs.readBoolean();
167 bs.readBoolean();
168
169 info.afterMarshall(wireFormat);
170
171 }
172
173 /**
174 * Un-marshal an object instance from the data input stream
175 *
176 * @param o the object to un-marshal
177 * @param dataIn the data input stream to build the object from
178 * @throws IOException
179 */
180 public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
181 super.looseUnmarshal(wireFormat, o, dataIn);
182
183 Message info = (Message)o;
184
185 info.beforeUnmarshall(wireFormat);
186
187 info.setProducerId((org.apache.activemq.command.ProducerId)looseUnmarsalCachedObject(wireFormat, dataIn));
188 info.setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
189 info.setTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
190 info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
191 info.setMessageId((org.apache.activemq.command.MessageId)looseUnmarsalNestedObject(wireFormat, dataIn));
192 info.setOriginalTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
193 info.setGroupID(looseUnmarshalString(dataIn));
194 info.setGroupSequence(dataIn.readInt());
195 info.setCorrelationId(looseUnmarshalString(dataIn));
196 info.setPersistent(dataIn.readBoolean());
197 info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
198 info.setPriority(dataIn.readByte());
199 info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
200 info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
201 info.setType(looseUnmarshalString(dataIn));
202 info.setContent(looseUnmarshalByteSequence(dataIn));
203 info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
204 info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
205 info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
206 info.setCompressed(dataIn.readBoolean());
207 info.setRedeliveryCounter(dataIn.readInt());
208
209 if (dataIn.readBoolean()) {
210 short size = dataIn.readShort();
211 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
212 for (int i = 0; i < size; i++) {
213 value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
214 }
215 info.setBrokerPath(value);
216 } else {
217 info.setBrokerPath(null);
218 }
219 info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
220 info.setUserID(looseUnmarshalString(dataIn));
221 info.setRecievedByDFBridge(dataIn.readBoolean());
222 info.setDroppable(dataIn.readBoolean());
223
224 info.afterUnmarshall(wireFormat);
225
226 }
227
228 /**
229 * Write the booleans that this object uses to a BooleanStream
230 */
231 public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
232
233 Message info = (Message)o;
234
235 info.beforeMarshall(wireFormat);
236
237 super.looseMarshal(wireFormat, o, dataOut);
238 looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
239 looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
240 looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
241 looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
242 looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
243 looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
244 looseMarshalString(info.getGroupID(), dataOut);
245 dataOut.writeInt(info.getGroupSequence());
246 looseMarshalString(info.getCorrelationId(), dataOut);
247 dataOut.writeBoolean(info.isPersistent());
248 looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
249 dataOut.writeByte(info.getPriority());
250 looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
251 looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
252 looseMarshalString(info.getType(), dataOut);
253 looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
254 looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
255 looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
256 looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
257 dataOut.writeBoolean(info.isCompressed());
258 dataOut.writeInt(info.getRedeliveryCounter());
259 looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
260 looseMarshalLong(wireFormat, info.getArrival(), dataOut);
261 looseMarshalString(info.getUserID(), dataOut);
262 dataOut.writeBoolean(info.isRecievedByDFBridge());
263 dataOut.writeBoolean(info.isDroppable());
264
265 }
266 }