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 Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

    • AbstractConnectionOperations

      public AbstractConnectionOperations()
  • Method Details

    • addConnectionCustomizer

      public void addConnectionCustomizer(@NonNull @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. The added customizer will be sorted according to its order using the OrderUtil.sort(List) method.
      Parameters:
      connectionCustomizer - the connection customizer to add
      Since:
      4.11
    • openConnection

      protected abstract C openConnection(ConnectionDefinition definition)
      Opens a new connection.
      Parameters:
      definition - The connection definition
      Returns:
      The connection
    • setupConnection

      protected abstract void setupConnection(ConnectionStatus<C> connectionStatus)
      Setups the connection after it have been open.
      Parameters:
      connectionStatus - The connection status
    • closeConnection

      protected abstract void closeConnection(ConnectionStatus<C> connectionStatus)
      Closed the connection.
      Parameters:
      connectionStatus - The connection status
    • findConnectionStatus

      public final Optional<ConnectionStatus<C>> findConnectionStatus()
      Description copied from interface: ConnectionOperations
      Obtains the current connection.
      Specified by:
      findConnectionStatus in interface ConnectionOperations<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 interface ConnectionOperations<C>
      Type Parameters:
      R - The result
      Parameters:
      definition - The connection definition
      callback - 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 call SynchronousConnectionManager.complete(ConnectionStatus) after the connection is not needed anymore.
      Specified by:
      getConnection in interface SynchronousConnectionManager<C>
      Parameters:
      definition - The connection definition.
      Returns:
      The connection status
    • complete

      public void complete(@NonNull @NonNull ConnectionStatus<C> status)
      Description copied from interface: SynchronousConnectionManager
      Completes the connection. Closes it if the connection was open before.
      Specified by:
      complete in interface SynchronousConnectionManager<C>
      Parameters:
      status - The connection status