1 /*** 2 * 3 * Copyright 2004 Protique Ltd 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 **/ 18 19 package org.codehaus.activemq.service.impl; 20 21 import org.codehaus.activemq.message.MessageAck; 22 import org.codehaus.activemq.service.MessageContainer; 23 import org.codehaus.activemq.service.MessageIdentity; 24 25 import javax.jms.JMSException; 26 27 28 /*** 29 * An entry for a message to be dispatched 30 * 31 * @version $Revision: 1.5 $ 32 */ 33 class MessagePointer { 34 private MessageContainer container; 35 private MessageIdentity messageIdentity; 36 private boolean dispatched; 37 private boolean read; 38 private boolean redelivered; 39 40 41 /*** 42 * Create a message ptr 43 * 44 * @param container the container where the message is held 45 * @param messageIdentity the id of the message 46 * @throws JMSException 47 */ 48 49 public MessagePointer(MessageContainer container, MessageIdentity messageIdentity) throws JMSException { 50 this.container = container; 51 this.messageIdentity = messageIdentity; 52 this.container.registerMessageInterest(this.messageIdentity); 53 } 54 55 56 /*** 57 * Reset default states for this MessagePointer 58 */ 59 60 public void reset() { 61 this.dispatched = false; 62 this.read = false; 63 } 64 65 /*** 66 * Simply remove the interest in the message 67 * 68 * @throws JMSException 69 */ 70 71 public void clear() throws JMSException { 72 container.unregisterMessageInterest(messageIdentity, null); 73 } 74 75 76 /*** 77 * Notify the container it should delete the message 78 * 79 * @param ack 80 * @throws JMSException 81 */ 82 83 public void delete(MessageAck ack) throws JMSException { 84 clear(); 85 container.delete(messageIdentity, ack); 86 } 87 88 /*** 89 * @return Returns the container. 90 */ 91 public MessageContainer getContainer() { 92 return container; 93 } 94 95 /*** 96 * @param container The container to set. 97 */ 98 public void setContainer(MessageContainer container) { 99 this.container = container; 100 } 101 102 /*** 103 * @return Returns the dispatched. 104 */ 105 public boolean isDispatched() { 106 return dispatched; 107 } 108 109 /*** 110 * @param dispatched The dispatched to set. 111 */ 112 public void setDispatched(boolean dispatched) { 113 this.dispatched = dispatched; 114 } 115 116 /*** 117 * @return Returns the read. 118 */ 119 public boolean isRead() { 120 return read; 121 } 122 123 /*** 124 * @param read The read to set. 125 */ 126 public void setRead(boolean read) { 127 this.read = read; 128 } 129 130 public MessageIdentity getMessageIdentity() { 131 return messageIdentity; 132 } 133 134 public void setMessageIdentity(MessageIdentity messageIdentity) { 135 this.messageIdentity = messageIdentity; 136 } 137 /*** 138 * @return Returns the redilivered. 139 */ 140 public boolean isRedelivered() { 141 return redelivered; 142 } 143 /*** 144 * @param redelivered The redilivered to set. 145 */ 146 public void setRedelivered(boolean redelivered) { 147 this.redelivered = redelivered; 148 } 149 }