1 /*------------------------------------------------------------------------------
  2 Name:      PublishQos.cpp
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 #include <client/qos/PublishQos.h>
  8 #include <util/Global.h>
  9 
 10 using namespace org::xmlBlaster::util;
 11 using namespace org::xmlBlaster::util::qos;
 12 using namespace std;
 13 
 14 namespace org { namespace xmlBlaster { namespace client { namespace qos {
 15 
 16    PublishQos::PublishQos(Global& global)
 17       : ME("PublishQos"), global_(global), msgQosData_(global, "")
 18    {
 19       // deprecated
 20       //setLifeTime(global_.getProperty().getLongProperty("message.lifeTime", -1));
 21    }
 22 
 23    PublishQos::PublishQos(Global& global, const Destination& destination)
 24       : ME("PublishQos"), global_(global), msgQosData_(global, "")
 25    {
 26       addDestination(destination);
 27    }
 28 
 29    PublishQos::PublishQos(Global& global, bool persistent)
 30       : ME("PublishQos"), global_(global), msgQosData_(global, "")
 31    {
 32       setPersistent(persistent);
 33    }
 34 
 35    const MsgQosData& PublishQos::getData()
 36    {
 37       return msgQosData_;
 38    }
 39 
 40    PriorityEnum PublishQos::getPriority() const
 41    {
 42       return msgQosData_.getPriority();
 43    }
 44 
 45    /**
 46     * Set message priority value, PriorityEnum::NORM_PRIORITY (5) is default.
 47     * PriorityEnum::MIN_PRIORITY (0) is slowest
 48     * whereas PriorityEnum.MAX_PRIORITY (9) is highest priority.
 49     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.qos.publish.priority.html">The engine.qos.publish.priority requirement</a>
 50     */
 51    void PublishQos::setPriority(PriorityEnum priority)
 52    {
 53       msgQosData_.setPriority(priority);
 54    }
 55 
 56    /**
 57     * Send message to subscriber even if the content is the same as the previous?
 58     * <br />
 59     * Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.
 60     */
 61    void PublishQos::setForceUpdate(bool force)
 62    {
 63       msgQosData_.setForceUpdate(force);
 64    }
 65 
 66    /**
 67     * Control message life cycle on message expiry. 
 68     * @param forceDestroy true Force message destroy on message expire<br />
 69     *        false On message expiry messages which are already in callback queues are delivered.
 70     */
 71    void PublishQos::setForceDestroy(bool forceDestroy)
 72    {
 73       msgQosData_.setForceDestroy(forceDestroy);
 74    }
 75 
 76    void PublishQos::setSubscribable(bool isSubcribeable)
 77    {
 78       msgQosData_.setSubscribable(isSubcribeable);
 79    }
 80 
 81    /**
 82     * Mark a message to be readonly.
 83     * <br />
 84     * Only the first publish() will be accepted, followers are denied.
 85     */
 86    void PublishQos::setReadonly(bool readonly)
 87    {
 88       msgQosData_.setReadonly(readonly);
 89    }
 90 
 91    /**
 92     * Mark a message to be volatile or not.
 93     * <br />
 94     * A non-volatile messages stays in memory as long as the server runs<br />
 95     * A volatile messages exists only during publish and processing it (doing the updates).<br />
 96     * Defaults to false.
 97     */
 98    void PublishQos::setVolatile(bool volatileFlag)
 99    {
100       msgQosData_.setVolatile(volatileFlag);
101    }
102 
103    /**
104     * @see #isVolatile()
105     */
106    bool PublishQos::isVolatile()
107    {
108       return msgQosData_.isVolatile();
109    }
110 
111    /**
112     * Mark a message to be persistent.
113     */
114    void PublishQos::setPersistent(bool persistent)
115    {
116       msgQosData_.setPersistent(persistent);
117    }
118 
119    void PublishQos::setAdministrative(bool administrative)
120    {
121       msgQosData_.setAdministrative(administrative);
122    }
123 
124    /**
125     * The message expires after given milliseconds (message is erased).<p />
126     * Clients will get a notify about expiration.<br />
127     * This value is calculated relative to the rcvTimestamp in the xmlBlaster server.<br />
128     * Passing -1 milliseconds asks the server for unlimited livespan, which
129     * the server may or may not grant.
130     * @param lifeTime in milliseconds
131     */
132    void PublishQos::setLifeTime(long lifeTime)
133    {
134       msgQosData_.setLifeTime(lifeTime);
135    }
136 
137    /**
138     * Add a destination where to send the message.
139     * <p />
140     * Note you can invoke this multiple times to send to multiple destinations.
141     * @param destination  The loginName of a receiver or some destination XPath query
142     */
143    void PublishQos::addDestination(const Destination& destination)
144    {
145       msgQosData_.addDestination(destination);
146    }
147 
148    /**
149     * Access sender name.
150     * @return loginName of sender or null if not known
151     */
152    SessionNameRef PublishQos::getSender()
153    {
154       return msgQosData_.getSender();
155    }
156 
157    /*
158    void PublishQos::setSender(const SessionName& sender)
159    {
160       msgQosData_.setSender(sender);
161    }
162    */
163 
164    /**
165     * @param state The state to return to the server.
166     *   e.g. Contants.STATE_OK, see Constants::java
167     */
168    void PublishQos::setState(const string& state)
169    {
170       msgQosData_.setState(state);
171    }
172 
173    string PublishQos::getState()
174    {
175       return msgQosData_.getState();
176    }
177 
178    /**
179     * @param stateInfo The state info attribute to return to the server.
180     */
181    void PublishQos::setStateInfo(const string& stateInfo)
182    {
183       msgQosData_.setStateInfo(stateInfo);
184    }
185 
186    string PublishQos::getStateInfo()
187    {
188       return msgQosData_.getStateInfo();
189    }
190 
191    /**
192     * Administer/configure the message topic. 
193     */
194    void PublishQos::setTopicProperty(const TopicProperty& topicProperty)
195    {
196       msgQosData_.setTopicProperty(topicProperty);
197    }
198 
199    void PublishQos::setClientProperties(const QosData::ClientPropertyMap& cm)
200    {
201       msgQosData_.setClientProperties(cm);
202    }
203 
204    const QosData::ClientPropertyMap& PublishQos::getClientProperties() const
205    {
206       return msgQosData_.getClientProperties();
207    }
208 
209    /**
210     * Converts the data into a valid XML ASCII string.
211     * @return An XML ASCII string
212     */
213    string PublishQos::toString()
214    {
215       return toXml();
216    }
217 
218    /**
219     * Converts the data into a valid XML ASCII string.
220     * @return An XML ASCII string
221     */
222    string PublishQos::toXml()
223    {
224       return msgQosData_.toXml();
225    }
226 
227 }}}}


syntax highlighted by Code2HTML, v. 0.9.1