001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.catalina.tribes;
018:
019: import java.io.Serializable;
020: import org.apache.catalina.tribes.io.XByteBuffer;
021:
022: /**
023: * Message that is passed through the interceptor stack after the
024: * data serialized in the Channel object and then passed down to the
025: * interceptor and eventually down to the ChannelSender component
026: * @author Filip Hanik
027: *
028: */
029: public interface ChannelMessage extends Serializable {
030:
031: /**
032: * Get the address that this message originated from.
033: * Almost always <code>Channel.getLocalMember(boolean)</code><br>
034: * This would be set to a different address
035: * if the message was being relayed from a host other than the one
036: * that originally sent it.
037: * @return the source or reply-to address of this message
038: */
039: public Member getAddress();
040:
041: /**
042: * Sets the source or reply-to address of this message
043: * @param member Member
044: */
045: public void setAddress(Member member);
046:
047: /**
048: * Timestamp of when the message was created.
049: * @return long timestamp in milliseconds
050: */
051: public long getTimestamp();
052:
053: /**
054: *
055: * Sets the timestamp of this message
056: * @param timestamp The timestamp
057: */
058: public void setTimestamp(long timestamp);
059:
060: /**
061: * Each message must have a globally unique Id.
062: * interceptors heavily depend on this id for message processing
063: * @return byte
064: */
065: public byte[] getUniqueId();
066:
067: /**
068: * The byte buffer that contains the actual message payload
069: * @param buf XByteBuffer
070: */
071: public void setMessage(XByteBuffer buf);
072:
073: /**
074: * returns the byte buffer that contains the actual message payload
075: * @return XByteBuffer
076: */
077: public XByteBuffer getMessage();
078:
079: /**
080: * The message options is a 32 bit flag set
081: * that triggers interceptors and message behavior.
082: * @see Channel#send(Member[], Serializable, int)
083: * @see ChannelInterceptor#getOptionFlag
084: * @return int - the option bits set for this message
085: */
086: public int getOptions();
087:
088: /**
089: * sets the option bits for this message
090: * @param options int
091: * @see #getOptions()
092: */
093: public void setOptions(int options);
094:
095: /**
096: * Shallow clone, what gets cloned depends on the implementation
097: * @return ChannelMessage
098: */
099: public Object clone();
100:
101: /**
102: * Deep clone, all fields MUST get cloned
103: * @return ChannelMessage
104: */
105: public Object deepclone();
106: }
|