01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.catalina.tribes;
18:
19: import java.io.Serializable;
20:
21: /**
22: *
23: * <p>Title: ChannelListener</p>
24: *
25: * <p>Description: An interface to listens to incoming messages from a channel </p>
26: * When a message is received, the Channel will invoke the channel listener in a conditional sequence.
27: * <code>if ( listener.accept(msg,sender) ) listener.messageReceived(msg,sender);</code><br>
28: * A ChannelListener implementation MUST NOT return true on <code>accept(Serializable, Member)</code>
29: * if it doesn't intend to process the message. The channel can this way track whether a message
30: * was processed by an above application or if it was just received and forgot about, a featuer required
31: * to support message-response(RPC) calls<br>
32: *
33: * @author Filip Hanik
34: * @version 1.0
35: */
36:
37: public interface ChannelListener {
38:
39: /**
40: * Receive a message from the channel
41: * @param msg Serializable
42: * @param sender - the source of the message
43: */
44: public void messageReceived(Serializable msg, Member sender);
45:
46: /**
47: * Invoked by the channel to determine if the listener will process this message or not.
48: * @param msg Serializable
49: * @param sender Member
50: * @return boolean
51: */
52: public boolean accept(Serializable msg, Member sender);
53:
54: /**
55: *
56: * @param listener Object
57: * @return boolean
58: * @see Object#equals(Object)
59: */
60: public boolean equals(Object listener);
61:
62: /**
63: *
64: * @return int
65: * @see Object#hashCode(int)
66: */
67: public int hashCode();
68:
69: }
|