Class AbstractConnectionOperations<C>
java.lang.Object
io.micronaut.data.connection.support.AbstractConnectionOperations<C>
- Type Parameters:
C
- The connection type
- All Implemented Interfaces:
ConnectionOperations<C>
,SynchronousConnectionManager<C>
- Direct Known Subclasses:
DefaultDataSourceConnectionOperations
,HibernateConnectionOperations
@Internal
public abstract class AbstractConnectionOperations<C>
extends Object
implements ConnectionOperations<C>, SynchronousConnectionManager<C>
The abstract connection operations.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
closeConnection
(ConnectionStatus<C> connectionStatus) Closed the connection.void
complete
(@NonNull ConnectionStatus<C> status) Completes the connection.final <R> R
execute
(@NonNull ConnectionDefinition definition, @NonNull Function<ConnectionStatus<C>, R> callback) Execute a connection within the context of the function.final Optional<ConnectionStatus<C>>
Obtains the current connection.@NonNull ConnectionStatus<C>
getConnection
(@NonNull ConnectionDefinition definition) Opens or reuses the existing connection based on the definition.protected abstract C
openConnection
(ConnectionDefinition definition) Opens a new connection.protected abstract void
setupConnection
(ConnectionStatus<C> connectionStatus) Setups the connection after it have been open.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.data.connection.ConnectionOperations
executeRead, executeWrite, getConnectionStatus
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
AbstractConnectionOperations
public AbstractConnectionOperations()
-
-
Method Details
-
openConnection
Opens a new connection.- Parameters:
definition
- The connection definition- Returns:
- The connection
-
setupConnection
Setups the connection after it have been open.- Parameters:
connectionStatus
- The connection status
-
closeConnection
Closed the connection.- Parameters:
connectionStatus
- The connection status
-
findConnectionStatus
Description copied from interface:ConnectionOperations
Obtains the current connection.- Specified by:
findConnectionStatus
in interfaceConnectionOperations<C>
- Returns:
- The optional connection
-
execute
public final <R> R execute(@NonNull @NonNull ConnectionDefinition definition, @NonNull @NonNull Function<ConnectionStatus<C>, R> callback) Description copied from interface:ConnectionOperations
Execute a connection within the context of the function.- Specified by:
execute
in interfaceConnectionOperations<C>
- Type Parameters:
R
- The result- Parameters:
definition
- The connection definitioncallback
- The call back- Returns:
- The result
-
getConnection
@NonNull public @NonNull ConnectionStatus<C> getConnection(@NonNull @NonNull ConnectionDefinition definition) Description copied from interface:SynchronousConnectionManager
Opens or reuses the existing connection based on the definition. It's required to callSynchronousConnectionManager.complete(ConnectionStatus)
after the connection is not needed anymore.- Specified by:
getConnection
in interfaceSynchronousConnectionManager<C>
- Parameters:
definition
- The connection definition.- Returns:
- The connection status
-
complete
Description copied from interface:SynchronousConnectionManager
Completes the connection. Closes it if the connection was open before.- Specified by:
complete
in interfaceSynchronousConnectionManager<C>
- Parameters:
status
- The connection status
-