messageimpl.java
来自「OpenJMS是一个开源的Java Message Service API 1.」· Java 代码 · 共 597 行 · 第 1/2 页
JAVA
597 行
/** * Redistribution and use of this software and associated documentation * ("Software"), with or without modification, are permitted provided * that the following conditions are met: * * 1. Redistributions of source code must retain copyright * statements and notices. Redistributions must also contain a * copy of this document. * * 2. Redistributions in binary form must reproduce the * above copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other * materials provided with the distribution. * * 3. The name "Exolab" must not be used to endorse or promote * products derived from this Software without prior written * permission of Exoffice Technologies. For written permission, * please contact info@exolab.org. * * 4. Products derived from this Software may not be called "Exolab" * nor may "Exolab" appear in their names without prior written * permission of Exoffice Technologies. Exolab is a registered * trademark of Exoffice Technologies. * * 5. Due credit should be given to the Exolab Project * (http://www.exolab.org/). * * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * Copyright 2000-2005 (C) Exoffice Technologies Inc. All Rights Reserved. * * $Id: MessageImpl.java,v 1.2 2005/03/18 03:50:12 tanderson Exp $ */package org.exolab.jms.message;import java.io.Externalizable;import java.io.IOException;import java.io.ObjectInput;import java.io.ObjectOutput;import java.util.Enumeration;import javax.jms.Destination;import javax.jms.JMSException;import javax.jms.Message;import javax.jms.MessageNotReadableException;import javax.jms.MessageNotWriteableException;/** * This class implements the javax.jms.Message interface. * * @version $Revision: 1.2 $ $Date: 2005/03/18 03:50:12 $ * @author <a href="mailto:mourikis@exolab.org">Jim Mourikis</a> * @see javax.jms.Message */public class MessageImpl implements Message, Externalizable, Cloneable { /** * Object version no. for serialization. */ static final long serialVersionUID = 1; /** * This is a reference to the session that created the message. It * is used for acknowledgment */ private MessageSessionIfc _session = null; /** * Contains the message header information as specified by the JMS * specifications. */ private MessageHeader _messageHeader = new MessageHeader(); /** * The message properties */ private MessageProperties _messageProperties = new MessageProperties(); /** * If true, message properties are read-only. */ protected boolean _propertiesReadOnly = false; /** * If true, the message body is read-only. */ protected boolean _bodyReadOnly = false; /** * The time that the message was accepted by the server. */ protected long _acceptedTime; /** * The sequence number assigned to the message by server when the message * is accepted. */ protected long _sequenceNumber; /** * The identity of the connection that this was received on. */ protected transient long _connectionId; /** * This flag indicates that the message has been processed by the provider. */ protected boolean _processed = false; /** * Empty byte array for initialisation purposes. */ protected static final byte[] EMPTY = new byte[0]; /** * Default constructor, required to support externalization. */ public MessageImpl() { } /** * Clone an instance of this object. * * @return a new copy of this object * @throws CloneNotSupportedException if object or attributesare not * cloneable */ public Object clone() throws CloneNotSupportedException { MessageImpl result = (MessageImpl) super.clone(); result._messageHeader = (MessageHeader) _messageHeader.clone(); result._messageProperties = (MessageProperties) _messageProperties.clone(); return result; } // implementation of Externalizable.writeExternal public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(serialVersionUID); // the individual read-only states are meaningless when streaming; // they only affect the client when clearProperties or clearBody is // is invoked out.writeBoolean(_propertiesReadOnly || _bodyReadOnly); out.writeBoolean(_processed); out.writeLong(_acceptedTime); out.writeLong(_sequenceNumber); out.writeObject(_messageHeader); out.writeObject(_messageProperties); } // implementation of Externalizable.readExternal public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { long version = in.readLong(); if (version == serialVersionUID) { boolean readOnly = in.readBoolean(); _propertiesReadOnly = readOnly; _bodyReadOnly = readOnly; _processed = in.readBoolean(); _acceptedTime = in.readLong(); _sequenceNumber = in.readLong(); _messageHeader = (MessageHeader) in.readObject(); _messageProperties = (MessageProperties) in.readObject(); } else { throw new IOException("Incorrect version enountered: " + version + ". This version = " + serialVersionUID); } } public void setSession(MessageSessionIfc session) { _session = session; MessageId id = _messageHeader.getMessageId(); if (id != null) { _messageHeader.setAckMessageID(id.getId()); } } public String getJMSMessageID() throws JMSException { return _messageHeader.getJMSMessageID(); } public void setJMSMessageID(String id) throws JMSException { _messageHeader.setJMSMessageID(id); } /** * Returns the identifier of the message for acknowledgment. * This will typically be the same as that returned by * {@link #getJMSMessageID}, unless the message was republished after * its receipt. If the message is republished, this method will return * the original message identifier, whereas {@link #getJMSMessageID} will * return that of the last publication. * * @return the identifier of the message for acknowledgment */ public String getAckMessageID() { return _messageHeader.getAckMessageID(); } public long getJMSTimestamp() throws JMSException { return _messageHeader.getJMSTimestamp(); } public void setJMSTimestamp(long timestamp) throws JMSException { _messageHeader.setJMSTimestamp(timestamp); } /** * Return the wildcard value if there is one. * * @return the wildcard string */ public String getWildcard() { return _messageHeader.getWildcard(); } /** * Return the message id * * @return MessageId */ public MessageId getMessageId() { return _messageHeader.getMessageId(); } /** * Set the wildcard string. * * @param wildcard The wildcard. */ public void setWildcard(String wildcard) { _messageHeader.setWildcard(wildcard); } /** * Returns the value of the consumer identifier * * @return the value of the consumer identifier */ public long getConsumerId() { return _messageHeader.getConsumerId(); } /** * Set the value of the consumer identifer * * @param consumerId the consumer identifier */ public void setConsumerId(long consumerId) { _messageHeader.setConsumerId(consumerId); } // Not supported public byte[] getJMSCorrelationIDAsBytes() throws JMSException { return _messageHeader.getJMSCorrelationIDAsBytes(); } // Not supported public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException { _messageHeader.setJMSCorrelationIDAsBytes(correlationID); } public void setJMSCorrelationID(String correlationID) throws JMSException { _messageHeader.setJMSCorrelationID(correlationID); } public String getJMSCorrelationID() throws JMSException { return _messageHeader.getJMSCorrelationID(); } public Destination getJMSReplyTo() throws JMSException { return _messageHeader.getJMSReplyTo(); } public void setJMSReplyTo(Destination replyTo) throws JMSException { _messageHeader.setJMSReplyTo(replyTo); } public Destination getJMSDestination() throws JMSException { return _messageHeader.getJMSDestination(); } public void setJMSDestination(Destination destination)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?