001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jms.file;
031:
032: import java.lang.ref.*;
033:
034: import javax.jms.*;
035:
036: import com.caucho.jms.message.*;
037:
038: /**
039: * Entry in a file queue
040: */
041: public class FileQueueEntry {
042: private final long _id;
043:
044: FileQueueEntry _prev;
045: FileQueueEntry _next;
046:
047: private long _expiresTime;
048:
049: private MessageType _type;
050:
051: private SoftReference<MessageImpl> _msg;
052:
053: // True if the message has been read, but not yet committed
054: private boolean _isRead;
055:
056: public FileQueueEntry(long id, long expiresTime) {
057: _id = id;
058: _expiresTime = expiresTime;
059: }
060:
061: public FileQueueEntry(long id, long expiresTime, MessageType type) {
062: _id = id;
063: _expiresTime = expiresTime;
064: _type = type;
065: }
066:
067: public FileQueueEntry(long id, long expiresTime, MessageImpl msg) {
068: _id = id;
069: _expiresTime = expiresTime;
070: _msg = new SoftReference<MessageImpl>(msg);
071: }
072:
073: public long getId() {
074: return _id;
075: }
076:
077: public MessageType getType() {
078: return _type;
079: }
080:
081: public void setType(MessageType type) {
082: _type = type;
083: }
084:
085: public MessageImpl getMessage() {
086: SoftReference<MessageImpl> ref = _msg;
087:
088: if (ref != null)
089: return ref.get();
090: else
091: return null;
092: }
093:
094: public void setMessage(MessageImpl msg) {
095: _msg = new SoftReference<MessageImpl>(msg);
096: }
097:
098: public boolean isRead() {
099: return _isRead;
100: }
101:
102: public void setRead(boolean isRead) {
103: _isRead = isRead;
104: }
105: }
|