⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msgqosdata.java

📁 java开源的企业总线.xmlBlaster
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------Name:      MsgQosData.javaProject:   xmlBlaster.orgCopyright: xmlBlaster.org, see xmlBlaster-LICENSE file------------------------------------------------------------------------------*/package org.xmlBlaster.util.qos;import org.xmlBlaster.util.Global;import org.xmlBlaster.util.def.PriorityEnum;import org.xmlBlaster.util.SessionName;import org.xmlBlaster.util.property.PropEntry;import org.xmlBlaster.util.property.PropLong;import org.xmlBlaster.util.property.PropBoolean;import org.xmlBlaster.util.qos.address.Destination;import org.xmlBlaster.util.def.MethodName;import java.util.ArrayList;import java.util.Hashtable;import java.util.Iterator;import java.util.Map;import java.util.Properties;/** * Data container handling of publish() and update() quality of services.  * <p /> * QoS Informations sent from the client to the server via the publish() method and back via the update() method<br /> * They are needed to control xmlBlaster and inform the client. * <p /> * <p> * This data holder is accessible through 4 decorators, each of them allowing a specialized view on the data: * </p> * <ul> * <li>PublishQosServer Server side access</i> * <li>PublishQos Client side access</i> * <li>UpdateQosServer Server side access facade</i> * <li>UpdateQos Client side access facade</i> * </ul> * <p> * For the xml representation see MsgQosSaxFactory. * </p> * @see org.xmlBlaster.util.qos.MsgQosSaxFactory * @see org.xmlBlaster.test.classtest.qos.MsgQosFactoryTest * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/interface.publish.html">The interface.publish requirement</a> * @author xmlBlaster@marcelruff.info */public final class MsgQosData extends QosData implements java.io.Serializable, Cloneable{   private static final long serialVersionUID = 1L;   private transient I_MsgQosFactory factory;   private transient boolean isExpired = false; // cache the expired state for performance reasons   private TopicProperty topicProperty;   /**    * A PubSub message lease lasts forever if not otherwise specified. <p />    * The default message life cycle can be modified in xmlBlaster.properties:<br />    * <code>message.lease.maxLifeTime=3600000 # One hour lease</code><br />    * Every message can set the lifeTime value between 1 and maxLifeTime,     * -1L sets the life cycle on forever.    */ // TODO: Change to use glob instead of Global singleton! What about performance? Put variable into Global?   private static final long maxLifeTime = Global.instance().getProperty().get("message.maxLifeTime", -1L);   /** If Pub/Sub style update: contains the subscribe ID which caused this update */   private String subscriptionId;   public transient final static boolean DEFAULT_isSubscribable = true;   /** As default you can subscribe even PtP messages, set it to false if you don't want any subscriber to see your PtP message */   private PropBoolean subscribable = new PropBoolean(DEFAULT_isSubscribable);   /** the number of resend tries on failure */   private int redeliver;   private long queueIndex = -1L;   private long queueSize = -1L;   /** Internal use only, is this message sent from the persistence layer? */   private boolean fromPersistenceStore = false;   //public transient final static boolean DEFAULT_isVolatile = false;   //private boolean volatileFlag = DEFAULT_isVolatile;   /**    * Send message to subscriber even the content is the same as the previous?    * <br />    * Default is that xmlBlaster does send messages to subscribed clients, even the content didn't change.    */   public transient final static boolean DEFAULT_forceUpdate = true;   private PropBoolean forceUpdate = new PropBoolean(DEFAULT_forceUpdate);   public final static long DEFAULT_lifeTime = maxLifeTime;   /**     * A message expires after some time and will be discarded.    * Clients will get a notify about expiration.    * This is the configured lifeTime in millis of the message.    * It defaults to -1L (== forever).    */   private PropLong lifeTime = new PropLong(DEFAULT_lifeTime);   private long remainingLifeStatic = -1L;   public transient final static boolean DEFAULT_administrative = false;   private PropBoolean administrative = new PropBoolean(DEFAULT_administrative);   public transient final static boolean DEFAULT_forceDestroy = false;   private PropBoolean forceDestroy = new PropBoolean(DEFAULT_forceDestroy);   /** The priority of the message */   private PriorityEnum priority = PriorityEnum.NORM_PRIORITY;   private boolean priorityIsModified = false;   /**    * ArrayList for loginQoS, holding all destination addresses (Destination objects)    */   protected ArrayList destinationList;   protected transient Destination[] destinationArrCache;   public final static Destination[] EMPTY_DESTINATION_ARR = new Destination[0];   // TODO: Pass with client QoS!!!   private static final boolean receiveTimestampHumanReadable = Global.instance().getProperty().get("cb.receiveTimestampHumanReadable", false);   /**    * Constructs the specialized quality of service object for a publish() or update() call.    */   public MsgQosData(Global glob, MethodName methodName) {      this(glob, null, null, methodName);   }   /**    * Constructs the specialized quality of service object for a publish() or update() call.    * @param the XML based ASCII string   public MsgQosData(Global glob, String serialData) {      this(glob, null, serialData);   }    */   /**    * Constructs the specialized quality of service object for a publish() or update() call.    * @param factory The factory which knows how to serialize and parse me    */   public MsgQosData(Global glob, I_MsgQosFactory factory, MethodName methodName) {      this(glob, factory, null, methodName);   }   /**    * Constructs the specialized quality of service object for a publish() call.    * For internal use only, this message is sent from the persistence layer    * @param the XML based ASCII string    */   public MsgQosData(Global glob, I_MsgQosFactory factory, String serialData, MethodName methodName) {      super(glob, serialData, methodName);      this.factory = (factory == null) ? this.glob.getMsgQosFactory() : factory;   }   /**    * @see #isSubscribable()    */   public void setSubscribable(boolean isSubscribable) {      this.subscribable.setValue(isSubscribable);   }   /**    * Test if Publish/Subscribe style is used.    *    * @return true if Publish/Subscribe style is used<br />    *         false Only possible for PtP messages to keep PtP secret (you can't subscribe them)    */   public boolean isSubscribable() {      return this.subscribable.getValue();   }   public PropBoolean getSubscribableProp() {      return this.subscribable;   }   /**    * Test if Point to Point addressing style is used.    *    * @return true if addressing of the destination is used    *         false if Publish/Subscribe style is used    */   public boolean isPtp() {      return this.destinationList != null;   }   /**    * @param volatile true sets lifeTime=0 and forceDestroy=false<br />    *        false: does nothing    */   public void setVolatile(boolean volatileFlag) {      if (volatileFlag) {         setLifeTime(0L);         setForceDestroy(false);         setRemainingLifeStatic(0L); // not needed as server does set it      }      else {         //setLifeTime(maxLifeTime);         //setForceDestroy(false);      }      //this.volatileFlag = volatileFlag;   }   /**    * @return true/false    */   public boolean isVolatile() {      return getLifeTime()==0L && isForceDestroy()==false;      //return this.volatileFlag;   }   /*    * @return true If the default is the current setting.    public boolean isVolatileDefault() {      return this.DEFAULT_isVolatile == this.volatileFlag;   }    */   /**    * If Pub/Sub style update: contains the subscribe ID which caused this update    * @param subscriptionId null if PtP message    */   public void setSubscriptionId(String subscriptionId) {      this.subscriptionId = subscriptionId;   }   /**    * If Pub/Sub style update: contains the subscribe ID which caused this update    * @return subscribeId or null if PtP message    */   public String getSubscriptionId() {      return subscriptionId;   }   /**    * Send message to subscriber even if the content is the same as the previous.     * @param forceUpdate    * @see <a href="http://www.xmlBlaster.org/xmlBlaster/doc/requirements/engine.qos.publish.forceUpdate.html">The engine.qos.publish.forceUpdate requirement</a>    */   public void setForceUpdate(boolean forceUpdate) {      this.forceUpdate.setValue(forceUpdate);   }   /**    * @return true/false    */   public boolean isForceUpdate() {      return this.forceUpdate.getValue();   }   public PropBoolean getForceUpdateProp() {      return this.forceUpdate;   }   /**    * @return readonly Once published the message can't be changed.     */   public void setReadonly(boolean readonly) {      TopicProperty prop = getTopicProperty();      prop.setReadonly(true);   }   /**    * @return true/false    */   public boolean isReadonly() {      return getTopicProperty().isReadonly();   }   /**    * Set > 0 if the message probably is redelivered (number of retries).     * @param redeliver if == 0 The message is guaranteed to be delivered only once.    */   public void setRedeliver(int redeliver) {      this.redeliver = redeliver;   }   /**    * Increment the redeliver counter    */   public void incrRedeliver() {      this.redeliver++;   }   /**    * Returns > 0 if the message probably is redelivered.     * @return == 0 The message is guaranteed to be delivered only once.    */   public int getRedeliver() {      return redeliver;   }  /**    * @param queueSize The number of queued messages    */   public void setQueueSize(long queueSize) {      this.queueSize = queueSize;   }    /**    * @return The number of queued messages    */   public long getQueueSize() {      return queueSize;   }   /**    * @param queueIndex The index of the message in the queue    */   public void setQueueIndex(long queueIndex) {      this.queueIndex = queueIndex;   }   /**    * @return The index of the message in the queue    */   public long getQueueIndex() {      return queueIndex;   }   /**    * Message priority.    * @return priority 0-9    * @see org.xmlBlaster.util.def.PriorityEnum    */   public PriorityEnum getPriority() {      return priority;   }   /**    * Set message priority value, PriorityEnum.NORM_PRIORITY (5) is default.     * PriorityEnum.MIN_PRIORITY (0) is slowest    * whereas PriorityEnum.MAX_PRIORITY (9) is highest priority.    * @see org.xmlBlaster.util.def.PriorityEnum    */   public void setPriority(PriorityEnum priority) {      this.priority = priority;      this.priorityIsModified = true;   }   /**    * Internal use only, is this message sent from the persistence layer?    * @return true/false    */   public boolean isFromPersistenceStore() {      return fromPersistenceStore;   }   /**    * Internal use only, set if this message sent from the persistence layer    * @param true/false    */   public void setFromPersistenceStore(boolean fromPersistenceStore) {      this.fromPersistenceStore = fromPersistenceStore;   }   /**    * The life time of the message or -1L if forever    */   public long getLifeTime() {      return this.lifeTime.getValue();   }   public PropLong getLifeTimeProp() {      return this.lifeTime;   }   /**    * Control the life time of a message.     * <p/>    * This value is calculated relative to the rcvTimestamp in the xmlBlaster server.    * <p/>    * Passing -1 milliseconds asks the server for unlimited livespan, which    * the server may or may not grant.    * @param lifeTime The life time of the message or -1L if forever.    * <p>  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -