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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConnectionCustomizer(@NonNull ConnectionCustomizer<C> connectionCustomizer) Adds a connection customizer to the list of customizers that will be notified before or after a call to the underlying data repository is issues.protected abstract voidcloseConnection(ConnectionStatus<C> connectionStatus) Closed the connection.voidcomplete(@NonNull ConnectionStatus<C> status) Completes the connection.final <R> Rexecute(@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 CopenConnection(ConnectionDefinition definition) Opens a new connection.protected abstract voidsetupConnection(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, waitMethods 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
-
addConnectionCustomizer
Adds a connection customizer to the list of customizers that will be notified before or after a call to the underlying data repository is issues. The added customizer will be sorted according to its order using theOrderUtil.sort(List)method.- Parameters:
connectionCustomizer- the connection customizer to add- Since:
- 4.11
-
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:ConnectionOperationsObtains the current connection.- Specified by:
findConnectionStatusin 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:ConnectionOperationsExecute a connection within the context of the function.- Specified by:
executein 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:SynchronousConnectionManagerOpens 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:
getConnectionin interfaceSynchronousConnectionManager<C>- Parameters:
definition- The connection definition.- Returns:
- The connection status
-
complete
Description copied from interface:SynchronousConnectionManagerCompletes the connection. Closes it if the connection was open before.- Specified by:
completein interfaceSynchronousConnectionManager<C>- Parameters:
status- The connection status
-