documentation-website/Writerside/topics/Statement-Interceptors.md
DSL operations within a transaction create SQL statements, on which commands like Execute, Commit, and Rollback
are issued. Exposed provides
the StatementInterceptor
interface that allows you to implement your own logic before and after these specific steps in a statement's lifecycle.
registerInterceptor() and unregisterInterceptor() can be used to enable and disable a custom interceptor in a single
transaction.
To use a custom interceptor that acts on all transactions, implement the
GlobalStatementInterceptor
interface instead. Exposed uses the Java SPI ServiceLoader to discover and load any implementations of this interface.
In this situation, a new file should be created in the resources folder named:
META-INF/services/org.jetbrains.exposed.v1.core.statements.GlobalStatementInterceptor
The contents of this file should be the fully qualified class names of all custom implementations.
Exposed additionally provides both
the SuspendStatementInterceptor
and GlobalSuspendStatementInterceptor
interfaces.
As in the previous section, these interfaces allow you to implement your own logic at the same points in a statement's lifecycle, but their methods allow the use of suspending functions and database operation methods specific to R2DBC suspend transactions.
These custom suspend interceptors can be enabled and disabled in the same way as the core statement interceptors.