public class DefaultServerChooser extends java.lang.Object implements ServerChooser
Constructor and Description |
---|
DefaultServerChooser() |
Modifier and Type | Method and Description |
---|---|
DefaultServerChooser |
add(java.lang.String uri)
Adds a URI to self.
|
<T extends java.util.Collection<java.lang.String>> |
addAll(T uris)
Adds URIs to self.
|
Authenticator |
getCurrentAuthenticator()
Returns the Authenticator instance associated with the current URI.
|
java.lang.String |
getCurrentURI()
Gets the current URI.
|
java.lang.String |
getError()
Provides additional details to be included in an exception thrown when the AMPS instance(s)
are not available.
|
void |
next()
Advances to the next URI in the list of URIs.
|
void |
reportFailure(java.lang.Exception exception,
ConnectionInfo info)
Called by
HAClient when an error occurs connecting to the current URI,
and/or when an error occurs logging on. |
void |
reportSuccess(ConnectionInfo info)
Report success is not used in this implementation.
|
public DefaultServerChooser add(java.lang.String uri)
uri
- The AMPS URI to add to the list.public <T extends java.util.Collection<java.lang.String>> DefaultServerChooser addAll(T uris)
T
- any type that extends Collection
of String
uris
- The AMPS URIs to add to the list.public java.lang.String getCurrentURI()
getCurrentURI
in interface ServerChooser
public Authenticator getCurrentAuthenticator()
getCurrentAuthenticator
in interface ServerChooser
Authenticator
or null if none is required for logon.public void reportFailure(java.lang.Exception exception, ConnectionInfo info) throws java.lang.Exception
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.reportFailure
in interface ServerChooser
exception
- The exception associated with this failure.info
- Information about the connection that failed.java.lang.Exception
- Allows any exception to be thrown: the exception will be reported to the ExceptionListener registered for the clientpublic void reportSuccess(ConnectionInfo info)
reportSuccess
in interface ServerChooser
info
- Information about the successful connection.public void next()
public java.lang.String getError()
HAClient
when creating an exception.getError
in interface ServerChooser
String
with information about the connection that failed and the
reason for the failure. When no further information is available, returns an empty string.