public final class ConnectionState extends Object
notifyConnectionClosed() and
notifyConnectionError(boolean, LdapException), correspond to
methods in the ConnectionEventListener interface except that they
return a boolean indicating whether the transition was successful or not.| Constructor and Description |
|---|
ConnectionState()
Creates a new connection state which is initially valid.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConnectionEventListener(ConnectionEventListener listener)
Registers the provided connection event listener so that it will be
notified when this connection is closed by the application, receives an
unsolicited notification, or experiences a fatal error.
|
LdapException |
getConnectionError()
Returns the error that caused the connection to fail, or
null if
the connection has not failed. |
boolean |
isClosed()
Indicates whether or not this connection has been explicitly closed by
calling
close. |
boolean |
isValid()
Returns
true if the associated connection has not been closed and
no fatal errors have been detected. |
boolean |
notifyConnectionClosed()
Attempts to transition this connection state to closed and invokes event
listeners if successful.
|
boolean |
notifyConnectionError(boolean isDisconnectNotification,
LdapException error)
Attempts to transition this connection state to error and invokes event
listeners if successful.
|
void |
notifyUnsolicitedNotification(ExtendedResult notification)
Notifies event listeners of the provided unsolicited notification if the
state is valid.
|
void |
removeConnectionEventListener(ConnectionEventListener listener)
Removes the provided connection event listener from this connection so
that it will no longer be notified when this connection is closed by the
application, receives an unsolicited notification, or experiences a fatal
error.
|
public ConnectionState()
public void addConnectionEventListener(ConnectionEventListener listener)
listener - The listener which wants to be notified when events occur on
this connection.IllegalStateException - If this connection has already been closed, i.e. if
isClosed() == true.NullPointerException - If the listener was null.public LdapException getConnectionError()
null if
the connection has not failed.null if
the connection has not failed.public boolean isClosed()
close. This method will not return true if a
fatal error has occurred on the connection unless close has been
called.true if this connection has been explicitly closed by
calling close, or false otherwise.public boolean isValid()
true if the associated connection has not been closed and
no fatal errors have been detected.true if this connection is valid, false
otherwise.public boolean notifyConnectionClosed()
true if the state changed to closed, or false if
the state was already closed.ConnectionEventListener.handleConnectionClosed()public boolean notifyConnectionError(boolean isDisconnectNotification, LdapException error)
isDisconnectNotification - true if the error was triggered by a disconnect
notification sent by the server, otherwise false.error - The exception that is about to be thrown to the application.true if the state changed to error, or false if
the state was already error or closed.ConnectionEventListener.handleConnectionError(boolean,
LdapException)public void notifyUnsolicitedNotification(ExtendedResult notification)
notification - The unsolicited notification.ConnectionEventListener.handleUnsolicitedNotification(ExtendedResult)public void removeConnectionEventListener(ConnectionEventListener listener)
listener - The listener which no longer wants to be notified when events
occur on this connection.NullPointerException - If the listener was null.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.