001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * Copyright 2005 Hiram Chirino
005     * 
006     * Licensed under the Apache License, Version 2.0 (the "License"); 
007     * you may not use this file except in compliance with the License. 
008     * You may obtain a copy of the License at 
009     * 
010     * http://www.apache.org/licenses/LICENSE-2.0
011     * 
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS, 
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
015     * See the License for the specific language governing permissions and 
016     * limitations under the License. 
017     * 
018     **/
019    package org.activemq.service.boundedvm;
020    
021    import javax.jms.JMSException;
022    
023    import org.activemq.io.util.MemoryManageable;
024    import org.activemq.message.ActiveMQDestination;
025    import org.activemq.message.ActiveMQMessage;
026    import org.activemq.store.MessageStore;
027    
028    /**
029     * DurableMessagePointers are moved around in the DurableQueueBoundedMessageManager
030     * so that we remember the associated messageStore that the message has been 
031     * persisted to.
032     * 
033     * @version $Revision: 1.1.1.1 $
034     */
035    public class DurableMessagePointer implements MemoryManageable {
036        
037        private final MessageStore messageStore;
038        private final ActiveMQMessage message;
039            
040        public DurableMessagePointer(MessageStore messageStore, ActiveMQDestination destination, ActiveMQMessage message) {
041            this.messageStore = messageStore;
042            this.message = message;
043        }
044    
045        public ActiveMQMessage getMessage() {
046            return message;
047        }
048    
049        public Object getMemoryId() {
050            return message.getMemoryId();
051        }
052    
053        public int getMemoryUsage() {
054            return message.getMemoryUsage();
055        }
056    
057        public int incrementMemoryReferenceCount() {
058            return message.incrementMemoryReferenceCount();
059        }
060    
061        public int decrementMemoryReferenceCount() {
062            return message.decrementMemoryReferenceCount();
063        }
064    
065        public int getMemoryUsageReferenceCount() {
066            return message.getMemoryUsageReferenceCount();
067        }
068        
069        public int incrementDeliveryCount() throws JMSException {
070            return message.incrementDeliveryCount();
071        }
072    
073        public int incrementRedeliveryCount() throws JMSException {
074            return message.incrementRedeliveryCount();
075        }
076    
077        /**
078         * @return Returns the messageStore.
079         */
080        public MessageStore getMessageStore() {
081            return messageStore;
082        }
083        
084        public String toString(){
085            return "DMP - msg = " +  message;
086        }
087        
088        public int getPriority() {
089            return message.getPriority();
090        }
091    }