jap.forward
Class JAPRoutingRegistrationStatusObserver

java.lang.Object
  extended by java.util.Observable
      extended by jap.forward.JAPRoutingRegistrationStatusObserver
All Implemented Interfaces:
java.util.Observer

public class JAPRoutingRegistrationStatusObserver
extends java.util.Observable
implements java.util.Observer

This class is the backend of the forwarding server registration visualization. It can be used for displaying the current registration status of the local forwarding server at the InfoServices. Also if there are registration issues, an errorcode with more detailed information is provided. This class sends a JAPRoutingMessage.REGISTRATION_STATUS_CHANGED to all observers, if the registration state or the errorcode has been changed. So the displayed information can be updated.


Field Summary
static int ERROR_INFOSERVICE_CONNECT_ERROR
          This is the errorcode, if we know at least one InfoService with a forwarder list but cannot reach any of those InfoServices (we will try it every 10 minutes again).
static int ERROR_NO_ERROR
          This is the errorcode returned in every state except STATE_INITIAL_REGISTRATION.
static int ERROR_NO_KNOWN_PRIMARY_INFOSERVICES
          This is the errorcode, if we don't know any InfoService with a forwarder list.
static int ERROR_UNKNOWN_ERROR
          This is the errorcode, if we know at least one InfoService with a forwarder list but only unknown errors occured (should not happen).
static int ERROR_VERIFICATION_ERROR
          This is the errorcode, if we could reach at least one InfoService with a forwarder list, but all successful reached InfoServices returned a verification error of our local forwarding server (maybe because of a running firewall).
private  int m_currentErrorCode
          Stores the current error code (only meaningful, if we are in STATE_NO_REGISTRATION).
private  int m_currentState
          Stores the current forwarding server registration state at the infoservices.
private  java.util.Vector m_propagandaInstances
          This is the list of all known propaganda instances.
static int STATE_DISABLED
          This is the state, if the propaganda for the local forwaring server is not running (usually this is only the case, when the forwarding server is not running).
static int STATE_INITIAL_REGISTRATION
          This is the state, when all propaganda instances are started (usually shortly after the start of the local forwarding server).
static int STATE_NO_REGISTRATION
          This is the state, if the propaganda is running but we have no valid registration at any infoservice.
static int STATE_SUCCESSFUL_REGISTRATION
          This is the state, if the propaganda is running and we have at least one valid registration at an InfoService.
 
Constructor Summary
JAPRoutingRegistrationStatusObserver()
          Creates a new instance of JAPRoutingRegistrationStatusObserver.
 
Method Summary
 int getCurrentErrorCode()
          Returns the current errorcode, if the current state is STATE_NO_REGISTRATION.
 int getCurrentState()
          Returns the current state of the local forwarding server registration at the infoservices.
 void update(java.util.Observable a_notifier, java.lang.Object a_message)
          This is the implementation of the observer of the propaganda instances and JAPRoutingSettings.
private  void updateCurrentState(boolean a_overwriteInitialRegistrationState)
          Updates the current state value and the errorcode value based on the internal stored list of all propaganda instances.
private  void updatePropagandaInstancesList(java.util.Vector a_newPropagandaInstancesList)
          Updates the list of all displayed propaganda instances.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_DISABLED

public static final int STATE_DISABLED
This is the state, if the propaganda for the local forwaring server is not running (usually this is only the case, when the forwarding server is not running).

See Also:
Constant Field Values

STATE_INITIAL_REGISTRATION

public static final int STATE_INITIAL_REGISTRATION
This is the state, when all propaganda instances are started (usually shortly after the start of the local forwarding server). This state prevents, that there are a lot of different states and errorcodes are displayed while the propaganda is started (because some registrations may fail, others are successful).

See Also:
Constant Field Values

STATE_NO_REGISTRATION

public static final int STATE_NO_REGISTRATION
This is the state, if the propaganda is running but we have no valid registration at any infoservice. The getCurrentErrorCode() method provides more information about the reason in that case.

See Also:
Constant Field Values

STATE_SUCCESSFUL_REGISTRATION

public static final int STATE_SUCCESSFUL_REGISTRATION
This is the state, if the propaganda is running and we have at least one valid registration at an InfoService.

See Also:
Constant Field Values

ERROR_NO_ERROR

public static final int ERROR_NO_ERROR
This is the errorcode returned in every state except STATE_INITIAL_REGISTRATION.

See Also:
Constant Field Values

ERROR_NO_KNOWN_PRIMARY_INFOSERVICES

public static final int ERROR_NO_KNOWN_PRIMARY_INFOSERVICES
This is the errorcode, if we don't know any InfoService with a forwarder list. So no registration is possible (every 10 minutes we will look in the database of all known InfoServices, whether we can find one then). This errorcode can only occur in STATE_NO_REGISTRATION.

See Also:
Constant Field Values

ERROR_INFOSERVICE_CONNECT_ERROR

public static final int ERROR_INFOSERVICE_CONNECT_ERROR
This is the errorcode, if we know at least one InfoService with a forwarder list but cannot reach any of those InfoServices (we will try it every 10 minutes again). This errorcode can only occur in STATE_NO_REGISTRATION.

See Also:
Constant Field Values

ERROR_VERIFICATION_ERROR

public static final int ERROR_VERIFICATION_ERROR
This is the errorcode, if we could reach at least one InfoService with a forwarder list, but all successful reached InfoServices returned a verification error of our local forwarding server (maybe because of a running firewall).

See Also:
Constant Field Values

ERROR_UNKNOWN_ERROR

public static final int ERROR_UNKNOWN_ERROR
This is the errorcode, if we know at least one InfoService with a forwarder list but only unknown errors occured (should not happen).

See Also:
Constant Field Values

m_propagandaInstances

private java.util.Vector m_propagandaInstances
This is the list of all known propaganda instances.


m_currentState

private int m_currentState
Stores the current forwarding server registration state at the infoservices.


m_currentErrorCode

private int m_currentErrorCode
Stores the current error code (only meaningful, if we are in STATE_NO_REGISTRATION).

Constructor Detail

JAPRoutingRegistrationStatusObserver

public JAPRoutingRegistrationStatusObserver()
Creates a new instance of JAPRoutingRegistrationStatusObserver. We do only some initialization here.

Method Detail

getCurrentState

public int getCurrentState()
Returns the current state of the local forwarding server registration at the infoservices.

Returns:
The current forwarding server registration state.

getCurrentErrorCode

public int getCurrentErrorCode()
Returns the current errorcode, if the current state is STATE_NO_REGISTRATION. In any other state always ERROR_NO_ERROR is returned. See the ERROR constants in this class to get more details for the errorcodes. The errorcodes shall help to localize registration issues.

Returns:
The current error code.

update

public void update(java.util.Observable a_notifier,
                   java.lang.Object a_message)
This is the implementation of the observer of the propaganda instances and JAPRoutingSettings. If the instances reach the state HALTED, they are not observed any more.

Specified by:
update in interface java.util.Observer
Parameters:
a_notifier - The propaganda instance, which has changed the state or the JAPRoutingSettings instance.
a_message - The notification message (should be null for propaganda instances and a JAPRoutingMessage for the JAPRoutingSettings instance).

updateCurrentState

private void updateCurrentState(boolean a_overwriteInitialRegistrationState)
Updates the current state value and the errorcode value based on the internal stored list of all propaganda instances.

Parameters:
a_overwriteInitialRegistrationState - If we are in STATE_INITIAL_REGISTRATION normally this method should not update the state and the errorcode if the registration is not finished yet. But after the initial registration is done (all propaganda instances have been started), the state constant and error code need to be updated, so also the STATE_INITIAL_REGISTRATION must be overwritten. If this parameter is true, also the initial registration state is overwritten, if this parameter is false, the initial registration state would not be changed (and also not the errorcode). If we are in any other state than STATE_INITIAL_REGISTRATION, we are not affected by this parameter.

updatePropagandaInstancesList

private void updatePropagandaInstancesList(java.util.Vector a_newPropagandaInstancesList)
Updates the list of all displayed propaganda instances. We add only new unknown instances here, because removing of the old ones is done automatically, when they are stopped.

Parameters:
a_newPropagandaInstancesList - A Vector with propaganda instances. The new ones are added to the internal list.