Class ProcessorOptionsSystemProperties

java.lang.Object
io.micronaut.inject.visitor.util.ProcessorOptionsSystemProperties

@Internal public final class ProcessorOptionsSystemProperties extends Object
Exposes the Micronaut processor options of a compilation as system properties, for the visitors that read them from there (in particular micronaut-openapi), and restores the previous values once the compilation is over.

The properties are applied when a processor is initialized, and restored when the last processor that acquired them releases them at the end of processing. Without that, in a long-lived JVM (a Gradle daemon, a test suite, an IDE) the options of one compilation would be seen by every later compilation.

A processor that is initialized but never asked to process anything never acquires the properties, so it does not hold them. When a compilation applies its options while nothing holds the properties of a previous compilation, those are restored first.

Since:
5.2.16
Author:
Denis Stepanov
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    acquire(Object processor)
    Marks the properties as used by the given processor until it releases them.
    static void
    apply(Object compilation, Map<String,String> options)
    Sets the Micronaut options of a compilation as system properties.
    static boolean
    process(Object processor, boolean processingOver, BooleanSupplier round)
    Runs a processing round of the given processor while it holds the properties, and releases them after the last round.
    static void
    release(Object processor)
    Releases the properties acquired by the given processor, restoring the previous values when no other processor holds them.

    Methods inherited from class Object

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

    • apply

      public static void apply(Object compilation, Map<String,String> options)
      Sets the Micronaut options of a compilation as system properties.
      Parameters:
      compilation - An object identifying the compilation, shared by its processors
      options - The processor options
    • acquire

      public static void acquire(Object processor)
      Marks the properties as used by the given processor until it releases them.
      Parameters:
      processor - The processor
    • process

      public static boolean process(Object processor, boolean processingOver, BooleanSupplier round)
      Runs a processing round of the given processor while it holds the properties, and releases them after the last round.
      Parameters:
      processor - The processor
      processingOver - Whether this is the last round
      round - The processing of the round
      Returns:
      The result of the round
    • release

      public static void release(Object processor)
      Releases the properties acquired by the given processor, restoring the previous values when no other processor holds them.
      Parameters:
      processor - The processor