View Javadoc

1   /*
2    * Copyright (c) 1998-2002 The Jgroup Team.
3    *
4    * This program is free software; you can redistribute it and/or modify
5    * it under the terms of the GNU Lesser General Public License version 2 as
6    * published by the Free Software Foundation.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Lesser General Public License for more details.
12   *
13   * You should have received a copy of the GNU Lesser General Public License
14   * along with this program; if not, write to the Free Software
15   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16   *
17   */
18  
19  package jgroup.core.multicast;
20  
21  import java.io.InputStream;
22  
23  import jgroup.core.MemberId;
24  
25  /**
26   *  This interface enables members to receive message delivery
27   *  notifications.  Members implementing this interface must be able to
28   *  react in a suitable way to the delivery of messages composed either
29   *  by single objects or an input stream.
30   *
31   *  @author Alberto Montresor
32   *  @author Hein Meling
33   *  @since Jgroup 0.7
34   */
35  public interface MulticastListener
36  {
37  
38    /**
39     *  Returns a string naming the protocol implemented by this multicast
40     *  listener.
41     */
42    public String getProtocolName();
43  
44  
45    /**
46     * Upcall that is invoked by Jgroup to deliver a message <code>msg</code>,
47     * corresponding to an input stream from which the message may be read.
48     *
49     * @param msg   the input stream from which the message can be read.
50     * @param sender  the sender of the multicast message
51     * @param seqNo  the sequence number of this multicast message 
52     * @return an object that will be delivered to the invoker through the
53     * <tt>AckListener</tt> object specified when multicasting the message.
54     */
55    public Object deliverStream(InputStream msg, MemberId sender, int seqNo);
56  
57  
58    /**
59     * Upcall that is invoked by Jgroup to deliver a message <code>msg</code>,
60     * corresponding to a single serialized object.
61     *
62     * @param msg    the object that was multicasted.
63     * @param sender  the sender of the multicast message
64     * @param seqNo  the sequence number of this multicast message 
65     * @return an object that will be delivered to the invoker through the
66     * <tt>AckListener</tt> object specified when multicasting the message.
67     */
68    public Object deliverObject(Object msg, MemberId sender, int seqNo);
69  
70  } // END MulticastListener