1 45 package org.exolab.jms.messagemgr; 46 47 import java.sql.Connection ; 48 import javax.jms.JMSException ; 49 50 import org.exolab.jms.message.MessageImpl; 51 52 53 60 class CachedMessageRef extends AbstractMessageRef { 61 62 65 private final MessageCache _cache; 66 67 68 75 public CachedMessageRef(MessageImpl message, boolean persistent, 76 MessageCache cache) { 77 super(message.getMessageId().getId(), persistent); 78 79 if (cache == null) { 80 throw new IllegalArgumentException ("Argument 'cache' is null"); 81 } 82 _cache = cache; 83 } 84 85 92 public CachedMessageRef(String messageId, boolean persistent, 93 MessageCache cache) { 94 super(messageId, persistent); 95 96 if (cache == null) { 97 throw new IllegalArgumentException ("Argument 'cache' is null"); 98 } 99 _cache = cache; 100 } 101 102 109 public MessageImpl getMessage() throws JMSException { 110 return _cache.getMessage(this); 111 } 112 113 118 public void destroy() throws JMSException { 119 if (!isDestroyed()) { 120 _cache.destroy(this); 121 setDestroyed(); 122 } 123 } 124 125 131 public void destroy(Connection connection) throws JMSException { 132 if (!isDestroyed()) { 133 _cache.destroy(this, connection); 134 setDestroyed(); 135 } 136 } 137 138 } 139 | Popular Tags |