package gw.api.productmodel

/**
 * <p>This class improves performance by enabling a thread-local cache to minimize
 * access to the global {@link com.guidewire.pc.system.lookuptables.AvailabilityLookupTableManager}.
 * This facility must only be used in cases like product model synchronization,
 * where the underlying policy data -- i.e., the data used to drive availability
 * logic, as specified in lookuptables.xml -- is unchanging.
 *
 * <p><b>Usage:</b></p>
 *
 * <p>Anytime you are about to process a large number of product model patterns,
 * <em>and</em> you know the underlying policy data will not be changing, you can
 * use Gosu's <code>using</code> clause to set up a new AvailabilityContextScope,
 * e.g.:
 * <pre>
 *   using (new AvailabilityContextScope()) {
 *     // sync with product model
 *   }
 * </pre>
 */
@ReadOnly
final class AvailabilityContextScope implements IReentrant {
  override function enter() {
    com.guidewire.pc.domain.availability.AvailabilityContextScopeInternal.push()
  }

  override function exit() {
    com.guidewire.pc.domain.availability.AvailabilityContextScopeInternal.pop()
  }
}
