mirror of https://github.com/apache/activemq.git
171 lines
7.8 KiB
C++
171 lines
7.8 KiB
C++
/*
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
or more contributor license agreements. See the NOTICE file
|
|
distributed with this work for additional information
|
|
regarding copyright ownership. The ASF licenses this file
|
|
to you under the Apache License, Version 2.0 (the
|
|
"License"); you may not use this file except in compliance
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, either express or implied. See the License for the
|
|
specific language governing permissions and limitations
|
|
under the License.
|
|
*/
|
|
|
|
#include "netinet/in.h"
|
|
#include "marshal/MessageMarshaller.h"
|
|
#include "command/Message.h"
|
|
#include "boost/shared_ptr.hpp"
|
|
|
|
using namespace ActiveMQ::Marshalling;
|
|
using namespace ActiveMQ::Command;
|
|
using namespace ActiveMQ::IO;
|
|
using std::auto_ptr;
|
|
using boost::shared_ptr;
|
|
|
|
/*
|
|
* Marshalling code for Open Wire Format for Message
|
|
*
|
|
* NOTE!: This file is autogenerated - do not modify!
|
|
* if you need to make a change, please see the Groovy scripts in the
|
|
* activemq-core module
|
|
*/
|
|
|
|
MessageMarshaller::MessageMarshaller()
|
|
{
|
|
// no-op
|
|
}
|
|
|
|
MessageMarshaller::~MessageMarshaller()
|
|
{
|
|
// no-op
|
|
}
|
|
|
|
/*
|
|
* Un-marshal an object instance from the data input stream
|
|
*/
|
|
void
|
|
MessageMarshaller::unmarshal(ProtocolFormat& wireFormat, IDataStructure& o, BinaryReader& dataIn, BooleanStream& bs)
|
|
{
|
|
BaseCommandMarshaller::unmarshal(wireFormat, o, dataIn, bs);
|
|
|
|
Message& info = (Message&) o;
|
|
info.setProducerId( shared_ptr<ProducerId>(static_cast<ProducerId*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setDestination( shared_ptr<ActiveMQDestination>(static_cast<ActiveMQDestination*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setTransactionId( shared_ptr<TransactionId>(static_cast<TransactionId*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setOriginalDestination( shared_ptr<ActiveMQDestination>(static_cast<ActiveMQDestination*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setMessageId( shared_ptr<MessageId>(static_cast<MessageId*>(unmarshalNestedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setOriginalTransactionId( shared_ptr<TransactionId>(static_cast<TransactionId*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setGroupID( unmarshalString(wireFormat, dataIn, bs) );
|
|
info.setGroupSequence( dataIn.readInt() );
|
|
info.setCorrelationId( unmarshalString(wireFormat, dataIn, bs) );
|
|
info.setPersistent( bs.readBoolean() );
|
|
info.setExpiration( unmarshalLong(wireFormat, dataIn, bs) );
|
|
info.setPriority( dataIn.readByte() );
|
|
info.setReplyTo( shared_ptr<ActiveMQDestination>(static_cast<ActiveMQDestination*>(unmarshalNestedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setTimestamp( unmarshalLong(wireFormat, dataIn, bs) );
|
|
info.setType( unmarshalString(wireFormat, dataIn, bs) );
|
|
info.setContent( unmarshalByteSequence(wireFormat, dataIn, bs) );
|
|
info.setMarshalledProperties( unmarshalByteSequence(wireFormat, dataIn, bs) );
|
|
info.setDataStructure( shared_ptr<IDataStructure>(static_cast<IDataStructure*>(unmarshalNestedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setTargetConsumerId( shared_ptr<ConsumerId>(static_cast<ConsumerId*>(unmarshalCachedObject(wireFormat, dataIn, bs).release())) );
|
|
info.setCompressed( bs.readBoolean() );
|
|
info.setRedeliveryCounter( dataIn.readInt() );
|
|
|
|
if (bs.readBoolean()) {
|
|
short size = dataIn.readShort();
|
|
std::vector<shared_ptr<const BrokerId> > value;
|
|
for( int i=0; i < size; i++ )
|
|
value.push_back(shared_ptr<BrokerId>(static_cast<BrokerId*>(unmarshalNestedObject(wireFormat,dataIn, bs).release())));
|
|
info.setBrokerPath( value );
|
|
}
|
|
info.setArrival( unmarshalLong(wireFormat, dataIn, bs) );
|
|
info.setUserID( unmarshalString(wireFormat, dataIn, bs) );
|
|
info.setRecievedByDFBridge( bs.readBoolean() );
|
|
|
|
}
|
|
|
|
/*
|
|
* Write the booleans that this object uses to a BooleanStream
|
|
*/
|
|
size_t
|
|
MessageMarshaller::marshal1(ProtocolFormat& wireFormat, const IDataStructure& o, BooleanStream& bs) {
|
|
Message& info = (Message&) o;
|
|
|
|
int rc = BaseCommandMarshaller::marshal1(wireFormat, info, bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getProducerId(), bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getDestination(), bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getTransactionId(), bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getOriginalDestination(), bs);
|
|
rc += marshal1NestedObject(wireFormat, info.getMessageId(), bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getOriginalTransactionId(), bs);
|
|
rc += writeString1(info.getGroupID(), bs);
|
|
rc += writeString1(info.getCorrelationId(), bs);
|
|
bs.writeBoolean(info.isPersistent());
|
|
rc += writeLong1(info.getExpiration(), bs);
|
|
rc += marshal1NestedObject(wireFormat, info.getReplyTo(), bs);
|
|
rc += writeLong1(info.getTimestamp(), bs);
|
|
rc += writeString1(info.getType(), bs);
|
|
bs.writeBoolean(!(info.getContent().empty()));
|
|
rc += info.getContent().empty() ? 0 : info.getContent().size()+4;
|
|
bs.writeBoolean(!(info.getMarshalledProperties().empty()));
|
|
rc += info.getMarshalledProperties().empty() ? 0 : info.getMarshalledProperties().size()+4;
|
|
rc += marshal1NestedObject(wireFormat, info.getDataStructure(), bs);
|
|
rc += marshal1CachedObject(wireFormat, info.getTargetConsumerId(), bs);
|
|
bs.writeBoolean(info.isCompressed());
|
|
rc += marshal1ObjectArray(wireFormat, info.getBrokerPath(), bs);
|
|
rc += writeLong1(info.getArrival(), bs);
|
|
rc += writeString1(info.getUserID(), bs);
|
|
bs.writeBoolean(info.isRecievedByDFBridge());
|
|
|
|
return rc + 9;
|
|
}
|
|
|
|
/*
|
|
* Write a object instance to data output stream
|
|
*/
|
|
void
|
|
MessageMarshaller::marshal2(ProtocolFormat& wireFormat, const IDataStructure& o, BinaryWriter& dataOut, BooleanStream& bs) {
|
|
// }
|
|
|
|
BaseCommandMarshaller::marshal2(wireFormat, o, dataOut, bs);
|
|
|
|
Message& info = (Message&) o;
|
|
marshal2CachedObject(wireFormat, info.getProducerId(), dataOut, bs);
|
|
marshal2CachedObject(wireFormat, info.getDestination(), dataOut, bs);
|
|
marshal2CachedObject(wireFormat, info.getTransactionId(), dataOut, bs);
|
|
marshal2CachedObject(wireFormat, info.getOriginalDestination(), dataOut, bs);
|
|
marshal2NestedObject(wireFormat, info.getMessageId(), dataOut, bs);
|
|
marshal2CachedObject(wireFormat, info.getOriginalTransactionId(), dataOut, bs);
|
|
writeString2(info.getGroupID(), dataOut, bs);
|
|
dataOut.writeInt(info.getGroupSequence());
|
|
writeString2(info.getCorrelationId(), dataOut, bs);
|
|
bs.readBoolean();
|
|
writeLong2(info.getExpiration(), dataOut, bs);
|
|
dataOut.writeByte(info.getPriority());
|
|
marshal2NestedObject(wireFormat, info.getReplyTo(), dataOut, bs);
|
|
writeLong2(info.getTimestamp(), dataOut, bs);
|
|
writeString2(info.getType(), dataOut, bs);
|
|
if(bs.readBoolean()) {
|
|
dataOut.writeInt(info.getContent().size());
|
|
dataOut.write(&((info.getContent())[0]), info.getContent().size());
|
|
}
|
|
if(bs.readBoolean()) {
|
|
dataOut.writeInt(info.getMarshalledProperties().size());
|
|
dataOut.write(&((info.getMarshalledProperties())[0]), info.getMarshalledProperties().size());
|
|
}
|
|
marshal2NestedObject(wireFormat, info.getDataStructure(), dataOut, bs);
|
|
marshal2CachedObject(wireFormat, info.getTargetConsumerId(), dataOut, bs);
|
|
bs.readBoolean();
|
|
dataOut.writeInt(info.getRedeliveryCounter());
|
|
marshal2ObjectArray(wireFormat, info.getBrokerPath(), dataOut, bs);
|
|
writeLong2(info.getArrival(), dataOut, bs);
|
|
writeString2(info.getUserID(), dataOut, bs);
|
|
bs.readBoolean();
|
|
}
|