1 45 46 package org.exolab.jms.messagemgr; 47 48 import javax.jms.JMSException ; 49 50 51 57 abstract class AbstractMessageRef implements MessageRef { 58 59 62 private String _messageId; 63 64 67 private final boolean _persistent; 68 69 72 private volatile int _count; 73 74 75 81 public AbstractMessageRef(String messageId, boolean persistent) { 82 _messageId = messageId; 83 _persistent = persistent; 84 _count = 0; 85 } 86 87 92 public String getMessageId() { 93 return _messageId; 94 } 95 96 102 public boolean isPersistent() { 103 return _persistent; 104 } 105 106 109 public void reference() { 110 ++_count; 111 } 112 113 119 public void dereference() throws JMSException { 120 if (!isDestroyed()) { 121 if (--_count <= 0) { 122 destroy(); 123 setDestroyed(); 124 } 125 } 126 } 127 128 133 protected boolean isDestroyed() { 134 return (_count < 0); 135 } 136 137 140 protected void setDestroyed() { 141 _count = -1; 142 } 143 144 } 145 | Popular Tags |