Class InternalWorkScope

java.lang.Object
io.hypersistence.optimizer.core.event.InternalWorkScope

public final class InternalWorkScope extends Object
The InternalWorkScope marks the current thread while the Optimizer does database work on its own behalf, like persisting the events through the host application's SessionFactory.

Since that SessionFactory is decorated by the runtime scanner, this work would otherwise trigger runtime events about the Optimizer itself (e.g., a StatementlessConnectionEvent for every flush, as the events are written with plain JDBC), and persisting those events would trigger new ones, over and over. The AbstractEventSender drops the events sent within this scope.

The scope is reentrant, and every enter() call must be paired with an exit() call in a finally block.

Since:
2.14.0
Author:
Vlad Mihalcea
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Enter the internal work scope on the current thread.
    static void
    Exit the internal work scope on the current thread.
    static boolean
    Check whether the current thread is doing internal Optimizer work.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • enter

      public static void enter()
      Enter the internal work scope on the current thread.
    • exit

      public static void exit()
      Exit the internal work scope on the current thread.
    • isActive

      public static boolean isActive()
      Check whether the current thread is doing internal Optimizer work.
      Returns:
      true if the current thread is within the internal work scope