com.crankuptheamps.client
Interface ServerChooser

All Known Implementing Classes:
DefaultServerChooser

public interface ServerChooser

Interface for choosing amongst multiple instances for both initial connection and reconnection. Used by HAClient to pick an initial server, and then pick a new one on failure.


Method Summary
 Authenticator getCurrentAuthenticator()
          Returns the Authenticator instance associated with the current URI.
 String getCurrentURI()
          Returns the current URI.
 String getError()
          Provides additional detail to be included in an exception thrown when the AMPS instance(s) are not available.
 void next()
          Advances the server chooser to the next server it deems appropriate to connect with.
 void reportFailure(Exception exception, ConnectionInfo info)
          Called by the HAClient when an error occurs connecting to the current URI, and/or when an error occurs logging on.
 void reportSuccess(ConnectionInfo info)
          Called by the HAClient when successfully connected and logged on to the current instance.
 

Method Detail

getCurrentURI

String getCurrentURI()
Returns the current URI.

Returns:
A string with the URI to connect to, or null if no server is available to connect to.

getCurrentAuthenticator

Authenticator getCurrentAuthenticator()
                                      throws Exception
Returns the Authenticator instance associated with the current URI.

Returns:
An Authenticator or null if none is required for logon.
Throws:
Exception

reportFailure

void reportFailure(Exception exception,
                   ConnectionInfo info)
Called by the HAClient when an error occurs connecting to the current URI, and/or when an error occurs logging on. Implementors will likely advance the current URI to the next one in a list, or choose to stay with the current one, based on the exception type.

Parameters:
exception - The exception associated with this failure.
info - Information about the connection that failed.

getError

String getError()
Provides additional detail to be included in an exception thrown when the AMPS instance(s) are not available. Called by the HAClient when creating an exception.

Returns:
An String with information about the connection that failed and the reason for the failure. When no further information is available, returns an empty string.

reportSuccess

void reportSuccess(ConnectionInfo info)
Called by the HAClient when successfully connected and logged on to the current instance.

Parameters:
info - Information about the successful connection.

next

void next()
Advances the server chooser to the next server it deems appropriate to connect with.