Class DelegatingSourceGenerationContext

java.lang.Object
io.micronaut.aot.core.codegen.DelegatingSourceGenerationContext
All Implemented Interfaces:
AOTContext

public abstract class DelegatingSourceGenerationContext extends Object implements AOTContext
Base class for source generation context which need to delegate to another one.
  • Constructor Details

    • DelegatingSourceGenerationContext

      public DelegatingSourceGenerationContext(AOTContext delegate)
  • Method Details

    • getPackageName

      @NonNull public @NonNull String getPackageName()
      Description copied from interface: AOTContext
      The package which should be used for generated classes.
      Specified by:
      getPackageName in interface AOTContext
      Returns:
      the package name
    • getConfiguration

      @NonNull public @NonNull Configuration getConfiguration()
      Description copied from interface: AOTContext
      Returns the source generators configuration.
      Specified by:
      getConfiguration in interface AOTContext
      Returns:
      the configuration
    • getAnalyzer

      @NonNull public @NonNull ApplicationContextAnalyzer getAnalyzer()
      Description copied from interface: AOTContext
      Returns the application context analyzer.
      Specified by:
      getAnalyzer in interface AOTContext
      Returns:
      the application context analyzer
    • registerGeneratedSourceFile

      public void registerGeneratedSourceFile(@NonNull @NonNull com.squareup.javapoet.JavaFile javaFile)
      Description copied from interface: AOTContext
      Registers a generated source file.
      Specified by:
      registerGeneratedSourceFile in interface AOTContext
      Parameters:
      javaFile - the file to be added.
    • registerStaticInitializer

      public void registerStaticInitializer(com.squareup.javapoet.MethodSpec staticInitializer)
      Description copied from interface: AOTContext
      Registers a code block to be executed statically when the optimized binary is loaded.
      Specified by:
      registerStaticInitializer in interface AOTContext
      Parameters:
      staticInitializer - the static initializer method
    • registerStaticOptimization

      public <T> void registerStaticOptimization(String className, Class<T> optimizationKind, Consumer<? super com.squareup.javapoet.CodeBlock.Builder> bodyBuilder)
      Registers a static optimization method. This will automatically create a class which implements the StaticOptimizations service type. The consumer should create a body which returns an instance of the optimization type.
      Specified by:
      registerStaticOptimization in interface AOTContext
      Type Parameters:
      T - the type class of the optimization
      Parameters:
      className - the name of the class to generate
      optimizationKind - the type of the optimization
      bodyBuilder - the builder of the body of the load() method
    • registerServiceImplementation

      public void registerServiceImplementation(Class<?> serviceType, String simpleServiceName)
      Registers a generated service type.
      Specified by:
      registerServiceImplementation in interface AOTContext
      Parameters:
      serviceType - the type of the service
      simpleServiceName - the simple name of the generated type
    • registerGeneratedResource

      public void registerGeneratedResource(@NonNull @NonNull String path, Consumer<? super File> consumer)
      Description copied from interface: AOTContext
      Registers a new generated resource.
      Specified by:
      registerGeneratedResource in interface AOTContext
      Parameters:
      path - the relative path to the resource (including file name)
      consumer - the consumer to be called when the resource is generated.
    • registerExcludedResource

      public void registerExcludedResource(@NonNull @NonNull String path)
      Description copied from interface: AOTContext
      Registers a resource path as excluded. Excluded resources should be removed, as much as possible, from the final binary/deliverable since they are either not used or substituted with code.
      Specified by:
      registerExcludedResource in interface AOTContext
      Parameters:
      path - the path of the resource to exclude
    • registerClassNeededAtCompileTime

      public void registerClassNeededAtCompileTime(@NonNull @NonNull Class<?> clazz)
      Description copied from interface: AOTContext
      Registers a class as needed at compile time (where compile time is the compile time of generated classes). This will typically be used when source generators need classes which are not on the application classpath.
      Specified by:
      registerClassNeededAtCompileTime in interface AOTContext
      Parameters:
      clazz - a class
    • registerBuildTimeInit

      public void registerBuildTimeInit(String className)
      Description copied from interface: AOTContext
      Registers a type as a requiring initialization at build time.
      Specified by:
      registerBuildTimeInit in interface AOTContext
      Parameters:
      className - the type
    • javaFile

      @NonNull public @NonNull com.squareup.javapoet.JavaFile javaFile(com.squareup.javapoet.TypeSpec typeSpec)
      Description copied from interface: AOTContext
      Generates a java file spec.
      Specified by:
      javaFile in interface AOTContext
      Parameters:
      typeSpec - the type spec of the main class
      Returns:
      a java file
    • addDiagnostics

      @NonNull public void addDiagnostics(String category, String message)
      Description copied from interface: AOTContext
      Adds a diagnostic message, which is going to be written in a log file.
      Specified by:
      addDiagnostics in interface AOTContext
      Parameters:
      category - a category for the message, typically corresponding to the source generator type
      message - a message to log
    • put

      public <T> void put(@NonNull @NonNull Class<T> type, @NonNull T value)
      Description copied from interface: AOTContext
      Stores an entry in the context. The entry may be read by other processors, as long as they are executed in the proper order.
      Specified by:
      put in interface AOTContext
      Type Parameters:
      T - the type of the value
      Parameters:
      type - the class of the value to store
      value - the value to store
    • get

      @NonNull public <T> @NonNull Optional<T> get(@NonNull @NonNull Class<T> type)
      Description copied from interface: AOTContext
      Reads an entry from the context.
      Specified by:
      get in interface AOTContext
      Type Parameters:
      T - the type of the entry
      Parameters:
      type - the class of the entry
      Returns:
      an empty value if absent
    • getDiagnostics

      @NonNull public @NonNull Map<String,List<String>> getDiagnostics()
      Description copied from interface: AOTContext
      Returns the diagnostics map.
      Specified by:
      getDiagnostics in interface AOTContext
      Returns:
      the diagnostics
    • getRuntime

      @NonNull public @NonNull Runtime getRuntime()
      Description copied from interface: AOTContext
      Returns the target runtime environment.
      Specified by:
      getRuntime in interface AOTContext
      Returns:
      target runtime
    • getBuildTimeInitClasses

      public Set<String> getBuildTimeInitClasses()
      Description copied from interface: AOTContext
      Returns the set of classes which require build time initialization.
      Specified by:
      getBuildTimeInitClasses in interface AOTContext
      Returns:
      the set of classes needing build time init
    • finish

      public void finish()
      Description copied from interface: AOTContext
      Performs actions which have to be done as late as possible during source generation.
      Specified by:
      finish in interface AOTContext