1 /*-----------------------------------------------------------------------------
2 Name: Destination.cpp
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 Comment: Holding destination address attributes
6 -----------------------------------------------------------------------------*/
7
8 #include <util/Destination.h>
9 #include <util/Global.h>
10
11 using namespace std;
12
13 namespace org { namespace xmlBlaster { namespace util {
14
15 Destination::Destination(Global& global,
16 const SessionName& sessionName,
17 const string &queryType,
18 bool forceQueuing)
19 : global_(global),
20 log_(global.getLog("org.xmlBlaster.util")),
21 sessionName_(0)
22 {
23 SessionName *p = new SessionName(global_, sessionName.getAbsoluteName());
24 SessionNameRef r(p);
25 sessionName_ = r;
26
27 queryType_ = queryType;
28 forceQueuing_ = forceQueuing;
29 }
30
31 Destination::Destination(Global& global,
32 const string& address,
33 const string &queryType,
34 bool forceQueuing)
35 : global_(global),
36 log_(global.getLog("org.xmlBlaster.util")),
37 sessionName_(0)
38 {
39 SessionName *p = new SessionName(global_, address);
40 SessionNameRef r(p);
41 sessionName_ = r;
42
43 queryType_ = queryType;
44 forceQueuing_ = forceQueuing;
45 }
46
47
48 Destination::Destination(const Destination& dest)
49 : global_(dest.global_), log_(dest.log_), sessionName_(0)
50 {
51 copy(dest);
52 }
53
54 Destination& Destination::operator =(const Destination& dest)
55 {
56 copy(dest);
57 return *this;
58 }
59
60 bool Destination::isXPathQuery() const
61 {
62 return queryType_ == "XPATH";
63 }
64
65 bool Destination::isExactAddress() const
66 {
67 return queryType_ == "EXACT";
68 }
69
70 bool Destination::forceQueuing() const
71 {
72 return forceQueuing_;
73 }
74
75 void Destination::forceQueuing(bool forceQueuing)
76 {
77 forceQueuing_ = forceQueuing;
78 }
79
80 /*
81 void Destination::setDestination(const SessionName& sessionName)
82 {
83 sessionName_ = sessionName;
84 }
85 */
86
87 SessionNameRef Destination::getDestination() const
88 {
89 return sessionName_;
90 }
91
92 void Destination::setQueryType(const string &queryType)
93 {
94 if (queryType.compare("EXACT") == 0) queryType_ = queryType;
95 else
96 if (queryType.compare("XPATH") == 0) {}
97 else
98 log_.error(ME, string("Sorry, destination queryType='")
99 + queryType_ + string("' is not supported"));
100 }
101
102 string Destination::toXml(const string &extraOffset) const
103 {
104 string offset = Constants::OFFSET + extraOffset;
105 string ret;
106 ret += offset + "<destination queryType='" + queryType_ + "'";
107 ret += " forceQueuing='" + lexical_cast<string>(forceQueuing()) + "'";
108 ret += ">" + sessionName_->getAbsoluteName() + "</destination>";
109 return ret;
110 }
111
112 }}} // namespace
syntax highlighted by Code2HTML, v. 0.9.1