1 /*------------------------------------------------------------------------------
  2 Name:      EraseQos.java
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 package org.xmlBlaster.client.qos;
  7 
  8 import java.util.Properties;
  9 
 10 import org.xmlBlaster.util.Global;
 11 import org.xmlBlaster.util.qos.QueryQosData;
 12 import org.xmlBlaster.util.def.MethodName;
 13 import org.xmlBlaster.util.qos.ClientProperty;
 14 
 15 /**
 16  * This class encapsulates the QoS of an erase() request. 
 17  * <p />
 18  * A full specified <b>erase</b> qos could look like this:<br />
 19  * <pre>
 20  *&lt;qos>
 21  *   &lt;erase forceDestroy='false'/>
 22  *&lt;/qos>
 23  * </pre>
 24  * <p />
 25  * see xmlBlaster/src/dtd/XmlQoS.xml
 26  * @see org.xmlBlaster.util.qos.QueryQosData
 27  * @see org.xmlBlaster.util.qos.QueryQosSaxFactory
 28  * @see <a href="http://www.xmlblaster.org/xmlBlaster/doc/requirements/interface.erase.html">erase interface</a>
 29  */
 30 public final class EraseQos
 31 {
 32    private String ME = "EraseQos";
 33    private final Global glob;
 34    private final QueryQosData queryQosData;
 35 
 36    /**
 37     * Constructor for default qos (quality of service).
 38     */
 39    public EraseQos(Global glob) {
 40       this(glob, null);
 41    }
 42 
 43    /**
 44     * Constructor for internal use. 
 45     * @param queryQosData The struct holding the data
 46     */
 47    public EraseQos(Global glob, QueryQosData queryQosData) {
 48       this.glob = (glob==null) ? Global.instance() : glob;
 49       this.queryQosData = (queryQosData==null) ? new QueryQosData(this.glob, this.glob.getQueryQosFactory(), MethodName.ERASE) : queryQosData;
 50       this.queryQosData.setMethod(MethodName.ERASE);
 51    }
 52 
 53    /**
 54     * Access the wrapped data holder
 55     */
 56    public QueryQosData getData() {
 57       return this.queryQosData;
 58    }
 59 
 60    /*
 61     * Notify the subscribers on erase. 
 62     * <p/>
 63     * Defaults to true. 
 64     * NOTE: This is not supported, currently only the subscriber decides if
 65     * he wants notification.
 66    public void notifySubscribers(boolean notify) {
 67       this.queryQosData.setWantNotify(notify);
 68    }
 69    */
 70 
 71    /**
 72     * Defaults to false: If a topic is still referenced by callback messages
 73     * it will be not erased immediately but we wait until all pending messages are delivered. 
 74     * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.message.lifecycle.html">engine.message.lifecycle requirement</a>
 75     */
 76    public void setForceDestroy(boolean forceDestroy) {
 77       this.queryQosData.setForceDestroy(forceDestroy);
 78    }
 79 
 80    /**
 81     * Mark the erase request to be persistent. 
 82     * <p>
 83     * NOTE: The request is only persistent in the client side
 84     * queue if we are polling for xmlBlaster.
 85     * </p>
 86     */
 87    public void setPersistent(boolean persistent) {
 88       this.queryQosData.setPersistent(persistent);
 89    }
 90 
 91    /**
 92     * Sets a client property (an application specific property) to the
 93     * given value
 94     * @param key
 95     * @param value
 96     */
 97    public void addClientProperty(String key, Object value) {
 98       this.queryQosData.addClientProperty(key, value);
 99    }
100 
101    /**
102     * Read back a property. 
103     * @return The client property or null if not found
104     */
105    public ClientProperty getClientProperty(String key) {
106       return this.queryQosData.getClientProperty(key);
107    }
108 
109    /**
110     * Converts the data into a valid XML ASCII string.
111     * @return An XML ASCII string
112     */
113    public String toString() {
114       return this.queryQosData.toXml();
115    }
116 
117    /**
118     * Converts the data into a valid XML ASCII string.
119     * @return An XML ASCII string
120     */
121    public String toXml() {
122       return this.queryQosData.toXml();
123    }
124 
125    /**
126     * Converts the data into a valid XML ASCII string.
127     * @return An XML ASCII string
128     */
129    public String toXml(Properties props) {
130       return this.queryQosData.toXml((String)null, props);
131    }
132 }


syntax highlighted by Code2HTML, v. 0.9.1