1 /*------------------------------------------------------------------------------
2 Name: UnSubscribeQueueEntry.cpp
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6
7 #include <util/queue/UnSubscribeQueueEntry.h>
8 #include <util/dispatch/I_ConnectionsHandler.h>
9
10 namespace org { namespace xmlBlaster { namespace util { namespace queue {
11
12 using namespace std;
13 using namespace org::xmlBlaster::util::dispatch;
14 using namespace org::xmlBlaster::util::qos;
15 using namespace org::xmlBlaster::util::key;
16 using namespace org::xmlBlaster::client::qos;
17 using namespace org::xmlBlaster::client::key;
18
19 UnSubscribeQueueEntry::UnSubscribeQueueEntry(Global& global, const UnSubscribeKey& unSubscribeKey, const UnSubscribeQos& unSubscribeQos, int priority, Timestamp uniqueId)
20 : MsgQueueEntry(global, unSubscribeKey.getData(), unSubscribeQos.getData(),
21 org::xmlBlaster::util::Constants::ENTRY_TYPE_MSG_RAW + "|" + org::xmlBlaster::util::MethodName::UNSUBSCRIBE,
22 priority,
23 unSubscribeQos.getData().isPersistent(),
24 uniqueId)
25 {
26 ME = "UnSubscribeQueueEntry";
27 }
28
29 MsgQueueEntry *UnSubscribeQueueEntry::getClone() const
30 {
31 return new UnSubscribeQueueEntry(*this);
32 }
33
34 bool UnSubscribeQueueEntry::isUnSubscribe() const {
35 return true;
36 }
37
38 // this should actually be in another interface but since it is an only method we put it here.
39 const MsgQueueEntry& UnSubscribeQueueEntry::send(I_ConnectionsHandler& connectionsHandler) const
40 {
41 if (log_.call()) log_.call(ME, "send");
42 if (statusQosData_) {
43 delete statusQosData_;
44 statusQosData_ = NULL;
45 }
46 if (log_.dump()) log_.dump(ME, string("send: ") + toXml());
47 // the return value is not stored ...
48 connectionsHandler.getConnection().unSubscribe(getUnSubscribeKey(), getUnSubscribeQos());
49
50 return *this;
51 }
52
53 UnSubscribeQos UnSubscribeQueueEntry::getUnSubscribeQos() const
54 {
55 const QueryQosData *qos = dynamic_cast<const QueryQosData *>(&msgUnit_->getQos());
56 return UnSubscribeQos(global_, *qos);
57 }
58
59 UnSubscribeKey UnSubscribeQueueEntry::getUnSubscribeKey() const
60 {
61 const QueryKeyData *key = dynamic_cast<const QueryKeyData *>(&msgUnit_->getKey());
62 return UnSubscribeKey(global_, *key);
63 }
64
65 UnSubscribeReturnQos UnSubscribeQueueEntry::getUnSubscribeReturnQos() const
66 {
67 return UnSubscribeReturnQos(global_, *statusQosData_);
68 }
69
70
71 string UnSubscribeQueueEntry::toXml(const string& indent) const
72 {
73 string extraOffset = " " + indent;
74 string ret = indent + "<unSubscribeQueueEntry>\n";
75 if (msgUnit_) {
76 ret += extraOffset + msgUnit_->toXml(indent);
77 }
78 ret += indent + "</unSubscribeQueueEntry>\n";
79 return ret;
80 }
81
82 }}}} // namespace
syntax highlighted by Code2HTML, v. 0.9.1