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.v3;
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 if (bs.readBoolean()) {
091 short size = dataIn.readShort();
092 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
093 for (int i = 0; i < size; i++) {
094 value[i] = (org.apache.activemq.command.BrokerId)tightUnmarsalNestedObject(wireFormat, dataIn, bs);
095 }
096 info.setCluster(value);
097 } else {
098 info.setCluster(null);
099 }
100 info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));
101 info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));
102
103 info.afterUnmarshall(wireFormat);
104
105 }
106
107 /**
108 * Write the booleans that this object uses to a BooleanStream
109 */
110 public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {
111
112 Message info = (Message)o;
113
114 info.beforeMarshall(wireFormat);
115
116 int rc = super.tightMarshal1(wireFormat, o, bs);
117 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);
118 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);
119 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);
120 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);
121 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);
122 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);
123 rc += tightMarshalString1(info.getGroupID(), bs);
124 rc += tightMarshalString1(info.getCorrelationId(), bs);
125 bs.writeBoolean(info.isPersistent());
126 rc += tightMarshalLong1(wireFormat, info.getExpiration(), bs);
127 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);
128 rc += tightMarshalLong1(wireFormat, info.getTimestamp(), bs);
129 rc += tightMarshalString1(info.getType(), bs);
130 rc += tightMarshalByteSequence1(info.getContent(), bs);
131 rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);
132 rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);
133 rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);
134 bs.writeBoolean(info.isCompressed());
135 rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);
136 rc += tightMarshalLong1(wireFormat, info.getArrival(), bs);
137 rc += tightMarshalString1(info.getUserID(), bs);
138 bs.writeBoolean(info.isRecievedByDFBridge());
139 bs.writeBoolean(info.isDroppable());
140 rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);
141 rc += tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);
142 rc += tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);
143
144 return rc + 9;
145 }
146
147 /**
148 * Write a object instance to data output stream
149 *
150 * @param o the instance to be marshaled
151 * @param dataOut the output stream
152 * @throws IOException thrown if an error occurs
153 */
154 public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {
155 super.tightMarshal2(wireFormat, o, dataOut, bs);
156
157 Message info = (Message)o;
158 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);
159 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);
160 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);
161 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);
162 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);
163 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);
164 tightMarshalString2(info.getGroupID(), dataOut, bs);
165 dataOut.writeInt(info.getGroupSequence());
166 tightMarshalString2(info.getCorrelationId(), dataOut, bs);
167 bs.readBoolean();
168 tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);
169 dataOut.writeByte(info.getPriority());
170 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);
171 tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);
172 tightMarshalString2(info.getType(), dataOut, bs);
173 tightMarshalByteSequence2(info.getContent(), dataOut, bs);
174 tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);
175 tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);
176 tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);
177 bs.readBoolean();
178 dataOut.writeInt(info.getRedeliveryCounter());
179 tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);
180 tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);
181 tightMarshalString2(info.getUserID(), dataOut, bs);
182 bs.readBoolean();
183 bs.readBoolean();
184 tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);
185 tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);
186 tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);
187
188 info.afterMarshall(wireFormat);
189
190 }
191
192 /**
193 * Un-marshal an object instance from the data input stream
194 *
195 * @param o the object to un-marshal
196 * @param dataIn the data input stream to build the object from
197 * @throws IOException
198 */
199 public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {
200 super.looseUnmarshal(wireFormat, o, dataIn);
201
202 Message info = (Message)o;
203
204 info.beforeUnmarshall(wireFormat);
205
206 info.setProducerId((org.apache.activemq.command.ProducerId)looseUnmarsalCachedObject(wireFormat, dataIn));
207 info.setDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
208 info.setTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
209 info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalCachedObject(wireFormat, dataIn));
210 info.setMessageId((org.apache.activemq.command.MessageId)looseUnmarsalNestedObject(wireFormat, dataIn));
211 info.setOriginalTransactionId((org.apache.activemq.command.TransactionId)looseUnmarsalCachedObject(wireFormat, dataIn));
212 info.setGroupID(looseUnmarshalString(dataIn));
213 info.setGroupSequence(dataIn.readInt());
214 info.setCorrelationId(looseUnmarshalString(dataIn));
215 info.setPersistent(dataIn.readBoolean());
216 info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));
217 info.setPriority(dataIn.readByte());
218 info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
219 info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
220 info.setType(looseUnmarshalString(dataIn));
221 info.setContent(looseUnmarshalByteSequence(dataIn));
222 info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
223 info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
224 info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
225 info.setCompressed(dataIn.readBoolean());
226 info.setRedeliveryCounter(dataIn.readInt());
227
228 if (dataIn.readBoolean()) {
229 short size = dataIn.readShort();
230 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
231 for (int i = 0; i < size; i++) {
232 value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
233 }
234 info.setBrokerPath(value);
235 } else {
236 info.setBrokerPath(null);
237 }
238 info.setArrival(looseUnmarshalLong(wireFormat, dataIn));
239 info.setUserID(looseUnmarshalString(dataIn));
240 info.setRecievedByDFBridge(dataIn.readBoolean());
241 info.setDroppable(dataIn.readBoolean());
242
243 if (dataIn.readBoolean()) {
244 short size = dataIn.readShort();
245 org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];
246 for (int i = 0; i < size; i++) {
247 value[i] = (org.apache.activemq.command.BrokerId)looseUnmarsalNestedObject(wireFormat, dataIn);
248 }
249 info.setCluster(value);
250 } else {
251 info.setCluster(null);
252 }
253 info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));
254 info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));
255
256 info.afterUnmarshall(wireFormat);
257
258 }
259
260 /**
261 * Write the booleans that this object uses to a BooleanStream
262 */
263 public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {
264
265 Message info = (Message)o;
266
267 info.beforeMarshall(wireFormat);
268
269 super.looseMarshal(wireFormat, o, dataOut);
270 looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);
271 looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);
272 looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);
273 looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);
274 looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);
275 looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);
276 looseMarshalString(info.getGroupID(), dataOut);
277 dataOut.writeInt(info.getGroupSequence());
278 looseMarshalString(info.getCorrelationId(), dataOut);
279 dataOut.writeBoolean(info.isPersistent());
280 looseMarshalLong(wireFormat, info.getExpiration(), dataOut);
281 dataOut.writeByte(info.getPriority());
282 looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);
283 looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);
284 looseMarshalString(info.getType(), dataOut);
285 looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);
286 looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);
287 looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);
288 looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);
289 dataOut.writeBoolean(info.isCompressed());
290 dataOut.writeInt(info.getRedeliveryCounter());
291 looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);
292 looseMarshalLong(wireFormat, info.getArrival(), dataOut);
293 looseMarshalString(info.getUserID(), dataOut);
294 dataOut.writeBoolean(info.isRecievedByDFBridge());
295 dataOut.writeBoolean(info.isDroppable());
296 looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);
297 looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);
298 looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);
299
300 }
301 }