| 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectuk.ac.ic.doc.automed.p2p.state.PeerStateHandler
public class PeerStateHandler
| Field Summary | |
|---|---|
protected  int | 
_currentState
 | 
private  java.util.List | 
_stateListeners
 | 
static int | 
STATE_HELLO_COMPLETE
 | 
static int | 
STATE_HELLO_INIT
 | 
static int | 
STATE_INIT
 | 
static int | 
STATE_JOINED_GLOBAL
 | 
static int | 
STATE_JOINED_LOCAL
 | 
static int | 
STATE_REGISTER_GLOBAL
 | 
static int | 
STATE_STAND_ALONE
 | 
| Constructor Summary | |
|---|---|
PeerStateHandler()
Creates a new instance of PeerStateHandler  | 
|
| Method Summary | |
|---|---|
 void | 
addListener(StateChangedListener listener)
Register an interested listener  | 
 void | 
changePeerState(int newState)
It handle all state transitions in one method, throwing exceptions when conflicts occur .  | 
 int | 
getPeerState()
Return the current peer state  | 
protected  void | 
notifyListeners()
Inform interested listeners of a state change event  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int STATE_INIT
public static final int STATE_STAND_ALONE
public static final int STATE_HELLO_INIT
public static final int STATE_HELLO_COMPLETE
public static final int STATE_JOINED_LOCAL
public static final int STATE_REGISTER_GLOBAL
public static final int STATE_JOINED_GLOBAL
protected int _currentState
private java.util.List _stateListeners
| Constructor Detail | 
|---|
public PeerStateHandler()
AutoMedPeer - a reference to the AutoMedPeer| Method Detail | 
|---|
public void addListener(StateChangedListener listener)
public void changePeerState(int newState)
                     throws StateChangedException
It handle all state transitions in one method, throwing exceptions when 
 conflicts occur
.
 
 This method is synchronized to make sure that peer's states are updated
 in order.
StateChangedExceptionprotected void notifyListeners()
public int getPeerState()
  | 
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||