util/queue/UnSubscribeQueueEntry.cpp

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 Name:      UnSubscribeQueueEntry.cpp
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 ------------------------------------------------------------------------------*/
00006 
00007 #include <util/queue/UnSubscribeQueueEntry.h>
00008 #include <util/dispatch/I_ConnectionsHandler.h>
00009 
00010 namespace org { namespace xmlBlaster { namespace util { namespace queue {
00011 
00012 using namespace std;
00013 using namespace org::xmlBlaster::util::dispatch;
00014 using namespace org::xmlBlaster::util::qos;
00015 using namespace org::xmlBlaster::util::key;
00016 using namespace org::xmlBlaster::client::qos;
00017 using namespace org::xmlBlaster::client::key;
00018 
00019 UnSubscribeQueueEntry::UnSubscribeQueueEntry(Global& global, const UnSubscribeKey& unSubscribeKey, const UnSubscribeQos& unSubscribeQos, int priority, Timestamp uniqueId)
00020    : MsgQueueEntry(global, unSubscribeKey.getData(), unSubscribeQos.getData(),
00021                    org::xmlBlaster::util::Constants::ENTRY_TYPE_MSG_RAW + "|" + org::xmlBlaster::util::MethodName::UNSUBSCRIBE,
00022                    priority,
00023                    unSubscribeQos.getData().isPersistent(),
00024                    uniqueId)
00025 {
00026    ME = "UnSubscribeQueueEntry";
00027 }
00028 
00029 MsgQueueEntry *UnSubscribeQueueEntry::getClone() const
00030 {
00031    return new UnSubscribeQueueEntry(*this);
00032 }
00033 
00034 bool UnSubscribeQueueEntry::isUnSubscribe() const {
00035    return true;
00036 }
00037 
00038 // this should actually be in another interface but since it is an only method we put it here.
00039 const MsgQueueEntry& UnSubscribeQueueEntry::send(I_ConnectionsHandler& connectionsHandler) const
00040 {
00041    if (log_.call()) log_.call(ME, "send");
00042    if (statusQosData_) {
00043       delete statusQosData_;
00044       statusQosData_ = NULL;
00045    }
00046    if (log_.dump()) log_.dump(ME, string("send: ") + toXml());
00047    // the return value is not stored ...
00048    connectionsHandler.getConnection().unSubscribe(getUnSubscribeKey(), getUnSubscribeQos());
00049 
00050    return *this;
00051 }
00052 
00053 UnSubscribeQos UnSubscribeQueueEntry::getUnSubscribeQos() const
00054 {
00055    const QueryQosData *qos = dynamic_cast<const QueryQosData *>(&msgUnit_->getQos());
00056    return UnSubscribeQos(global_, *qos);
00057 }
00058 
00059 UnSubscribeKey UnSubscribeQueueEntry::getUnSubscribeKey() const
00060 {
00061    const QueryKeyData *key = dynamic_cast<const QueryKeyData *>(&msgUnit_->getKey());
00062    return UnSubscribeKey(global_, *key);
00063 }
00064 
00065 UnSubscribeReturnQos UnSubscribeQueueEntry::getUnSubscribeReturnQos() const
00066 {
00067    return UnSubscribeReturnQos(global_, *statusQosData_);
00068 }
00069 
00070 
00071 string UnSubscribeQueueEntry::toXml(const string& indent) const
00072 {
00073    string extraOffset = "   " + indent;
00074    string ret = indent + "<unSubscribeQueueEntry>\n";
00075    if (msgUnit_) {
00076       ret += extraOffset + msgUnit_->toXml(indent);
00077    }
00078    ret += indent + "</unSubscribeQueueEntry>\n";
00079    return ret;
00080 }
00081 
00082 }}}} // namespace
00083 
00084