KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > tribe > adapters > MulticastRequestListener


1 /**
2  * Tribe: Group communication library.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: tribe@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.tribe.adapters;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.ArrayList JavaDoc;
29
30 import org.objectweb.tribe.common.Member;
31
32 /**
33  * This class defines a MulticastRequestListener to handle calls from a
34  * MulticastRequestAdapter. When MulticastRequestAdapter.multicastMessage(...)
35  * is called, the remote node must reply (possibly with a null message). The
36  * message handling is split in 2 callbacks:
37  * <p>
38  * 1. call to handleMessageSingleThreaded(...). This is done in mutual exclusion
39  * and no other message can be delivered until this function has returned. An
40  * object can be returned to pass temporary data to the second handler.
41  * <p>
42  * 2. handleMessageMultiThreaded is executed in a dedicated thread and return
43  * the result of the call in a Serializable object.
44  * <p>
45  * Note that any of these handlers might be empty and just return null.
46  *
47  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
48  * @version 1.0
49  */

50 public interface MulticastRequestListener
51 {
52
53   /**
54    * First callback to handle a message sent through
55    * MulticastRequestAdapter.multicastMessage(...). This method is executed in
56    * mutual exclusion and block subsequent message deliveries until this
57    * callback returns. The object returned by this function is used to pass
58    * temporary data to the second callback.
59    *
60    * @param msg the message received that needs to be handled
61    * @param sender the message sender
62    * @return the object to pass to handleMessageMultiThreaded
63    * @see MulticastRequestAdapter#multicastMessage(ArrayList, Serializable, int,
64    * long)
65    * @see #handleMessageMultiThreaded(Serializable, Member, Object)
66    */

67   Object JavaDoc handleMessageSingleThreaded(Serializable JavaDoc msg, Member sender);
68
69   /**
70    * Second callback to handle a message sent through
71    * MulticastRequestAdapter.multicastMessage(...). The code of this callback
72    * will execute in a dedicated thread and therefore will execute concurrently
73    * of other messages processing.
74    *
75    * @param msg the message received that needs to be handled
76    * @param sender the message sender
77    * @param handleMessageSingleThreadedResult result of the first callback (may
78    * be null)
79    * @return the reply to send back
80    * @see MulticastRequestAdapter#multicastMessage(ArrayList, Serializable, int,
81    * long)
82    */

83   Serializable JavaDoc handleMessageMultiThreaded(Serializable JavaDoc msg, Member sender,
84       Object JavaDoc handleMessageSingleThreadedResult);
85 }
Popular Tags