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   *  In order to be notified of state updates, the server replicas
23   *  must implement this interface.  Servers implementing this interface
24   *  should be considered <i>semi-actively</i> replicated, were one
25   *  of the servers is elected as the group leader.
26   *
27   *  Note that it is required that the state object returned by the
28   *  <code>getState()</code> method does implement/override the
29   *  <code>hashCode()</code> method, since that is used to determine
30   *  if the leader state should be sent to the followers.
31   *
32   *  @author Hein Meling
33   *  @since 3.0
34   */
35  public interface StateListener
36  {
37  
38    /**
39     *  Method <code>getState</code> is invoked by the group leader,
40     *  and should return its current state.
41     *
42     *  @return 
43     *    The state object
44     */
45    public Object getState();
46  
47    /**
48     *  Method <code>putState</code> is invoked on followers to inform
49     *  them about the new state of the group leader.
50     *
51     *  @param state
52     *    The state object
53     */
54    public void putState(Object state);
55  
56  } // END StateListener