Exposed
 

Statement Interceptors

Last modified: 03 March 2025

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:

The contents of this file should be the fully qualified class names of all custom implementations.