Interface InterceptorStrategy


@Incubating(since="8.0") public interface InterceptorStrategy
Strategy for resolving and managing Interceptor instances across session lifecycle boundaries.
Since:
8.0
  • Method Details

    • getInterceptorForSession

      Interceptor getInterceptorForSession(SessionFactoryImplementor sessionFactory)
      Obtain an interceptor for a newly created session.
    • releaseInterceptor

      default void releaseInterceptor(Interceptor interceptor)
      Release an interceptor when its session closes.
    • isScoped

      default boolean isScoped()
      Does this strategy produce session-scoped interceptors, i.e. a distinct interceptor instance per session?

      Consulted by noSessionInterceptorCreation() to determine whether a session-level interceptor should be suppressed: scoped interceptors are suppressed, while global and explicitly-provided instance interceptors are not.

    • registerSharedUse

      default void registerSharedUse(Interceptor interceptor)
      Register an additional holder of the given interceptor, which was already obtained from getInterceptorForSession(SessionFactoryImplementor), so that the strategy can track how many sessions are sharing it.

      Called when a child session is created sharing its parent's interceptor. Strategies that track per-instance state (such as ScopedInterceptorStrategy) use this to ref-count the underlying bean so it isn't destroyed while any holder is still using it.

    • getFactoryInterceptor

      @Deprecated(since="8.0") @Nullable default Interceptor getFactoryInterceptor()
      Deprecated.
      Return a factory-level interceptor, or null if this strategy does not provide one.
    • getFactoryInterceptorBean

      @Nullable default ManagedBean<? extends Interceptor> getFactoryInterceptorBean()
      Return a managed bean wrapping the factory-level interceptor, or null if this strategy does not provide one. The bean is not resolved until ManagedBean.getBeanInstance() is called.