Interface ConnectionCustomizer<C>

Type Parameters:
C - The connection type
All Superinterfaces:
io.micronaut.core.order.Ordered

public interface ConnectionCustomizer<C> extends io.micronaut.core.order.Ordered
Customizes connection before or after data repository call based on the provided ConnectionStatus. Implementations of this interface can modify the behavior of connections created by Micronaut Data or do what might be needed before or after call to the data repository (for example JDBC statement call).
Since:
4.11
Author:
radovanradic
See Also:
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    connectionOpened(ConnectionStatus<C> connectionStatus)
    Called when a new connection is opened, before it is used, both for a connection operation and for the connection of a transaction, which the transaction manager opens without going through intercept(Function).
    Intercept the connection operation.

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder
  • Method Details

    • intercept

      <R> Function<ConnectionStatus<C>, R> intercept(Function<ConnectionStatus<C>, R> operation)
      Intercept the connection operation.
      Type Parameters:
      R - The result
      Parameters:
      operation - The operation
      Returns:
      the operation callback
    • connectionOpened

      default void connectionOpened(ConnectionStatus<C> connectionStatus)
      Called when a new connection is opened, before it is used, both for a connection operation and for the connection of a transaction, which the transaction manager opens without going through intercept(Function). Register a ConnectionSynchronization on the status to act when the connection is completed and closed. If this method throws, the connection is completed and closed.
      Parameters:
      connectionStatus - The status of the new connection
      Since:
      5.3.0