Package com.lucimber.dbus.connection
Class ConnectionLifecycleManager
java.lang.Object
com.lucimber.dbus.connection.ConnectionLifecycleManager
Manages the lifecycle of a connection including connect, disconnect, and state transitions. This
class encapsulates connection state management and ensures thread-safe state transitions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for connection operations.static interfaceFunctional interface for disconnection operations. -
Constructor Summary
ConstructorsConstructorDescriptionConnectionLifecycleManager(ConnectionConfig config, String connectionId) Creates a new connection lifecycle manager. -
Method Summary
Modifier and TypeMethodDescriptionconnect(ConnectionLifecycleManager.ConnectionSupplier connectionSupplier) Initiates a connection attempt.disconnect(ConnectionLifecycleManager.DisconnectionSupplier disconnectionSupplier) Initiates disconnection.Gets the connection circuit breaker.Gets the error recovery manager.getState()Gets the current connection state.booleanChecks if disconnection is in progress.booleanChecks if the connection is currently connected.booleanChecks if a connection attempt is in progress.
-
Constructor Details
-
ConnectionLifecycleManager
Creates a new connection lifecycle manager.- Parameters:
config- the connection configurationconnectionId- unique identifier for this connection
-
-
Method Details
-
connect
public CompletionStage<ConnectionHandle> connect(ConnectionLifecycleManager.ConnectionSupplier connectionSupplier) Initiates a connection attempt.- Parameters:
connectionSupplier- supplier that performs the actual connection- Returns:
- completion stage that completes when connection is established
-
disconnect
public CompletionStage<Void> disconnect(ConnectionLifecycleManager.DisconnectionSupplier disconnectionSupplier) Initiates disconnection.- Parameters:
disconnectionSupplier- supplier that performs the actual disconnection- Returns:
- completion stage that completes when disconnection is done
-
getState
Gets the current connection state.- Returns:
- current connection state
-
isConnected
public boolean isConnected()Checks if the connection is currently connected.- Returns:
- true if connected, false otherwise
-
isConnecting
public boolean isConnecting()Checks if a connection attempt is in progress.- Returns:
- true if connecting, false otherwise
-
isClosing
public boolean isClosing()Checks if disconnection is in progress.- Returns:
- true if closing, false otherwise
-
getErrorRecoveryManager
Gets the error recovery manager.- Returns:
- error recovery manager
-
getConnectionCircuitBreaker
Gets the connection circuit breaker.- Returns:
- circuit breaker for connection operations
-