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;
20  
21  /**
22   * When performing an asynchronous internal group method invocation (IGMI),
23   * an invoker may specify a callback object. The task of this callback object
24   * is to collect regular values and exceptions returned by members executing
25   * the asynchronous IGMI. <p>
26   *
27   * For each of the members contained in the view in which the invocation is
28   * executed, methods <tt>result</tt> or <tt>exception</tt> are invoked on the
29   * callback object. If a member becomes unreachable before being able to return
30   * a value or an exception to the invoker, then the callback object is notified
31   * through the invocation of method <tt>exception</tt> with a
32   * <tt>RemoteException</tt> as argument. Otherwise, the regular value or the
33   * exception is communicated to the callback object through the invocation
34   * of methods <tt>result</tt> or <tt>exception</tt>. <p>
35   *
36   * In both these methods, the identifier of the member returning the value or
37   * the exception is provided. On the other hand, no invocation identifier is
38   * provided. If the invoker need to distinguish return values associated to
39   * distinct exceptions, distinct callback objects should be used.
40   *
41   * @author  Alberto Montresor
42   * @since   Jgroup 0.8
43   */
44  public interface  Callback
45  {
46  
47    /**
48     * Invoked by internal GMI service to notify this callback object that
49     * the member identified by <tt>MemberId</tt> has returned <tt>result</tt>.
50     *
51     * @param id      the member identifier
52     * @param result  the regular value returned by the asynchronous invocation
53     */
54    public void result(MemberId id, Object result);
55  
56  
57    /**
58     * Invoked by internal GMI service to notify this callback object that
59     * the member identified by <tt>MemberId</tt> has thrown <tt>e</tt>.
60     *
61     * @param id    the member identifier
62     * @param e     the exception thrown by the asynchronous invocation
63     */
64    public void exception(MemberId id, Exception e);
65  
66  
67  } // END Callback