Class ContextAotProcessor

java.lang.Object
org.springframework.context.aot.AbstractAotProcessor
org.springframework.context.aot.ContextAotProcessor

public abstract class ContextAotProcessor extends AbstractAotProcessor
Filesystem-based ahead-of-time (AOT) processing base implementation.

Concrete implementations are typically used to kick off optimization of an application in a build tool.

Since:
6.0
Author:
Stephane Nicoll, Andy Wilkinson, Phillip Webb, Sam Brannen
See Also:
  • Constructor Details

    • ContextAotProcessor

      protected ContextAotProcessor(Class<?> applicationClass, AbstractAotProcessor.Settings settings)
      Create a new processor for the specified application entry point and common settings.
      Parameters:
      applicationClass - the application entry point (class with a main() method)
      settings - the settings to apply
  • Method Details

    • getApplicationClass

      protected Class<?> getApplicationClass()
      Get the the application entry point (typically a class with a main() method).
    • process

      public org.springframework.javapoet.ClassName process()
      Invoke the processing by clearing output directories first, followed by performAotProcessing(GenericApplicationContext).
      Returns:
      the ClassName of the ApplicationContextInitializer entry point
    • prepareApplicationContext

      protected abstract GenericApplicationContext prepareApplicationContext(Class<?> applicationClass)
      Prepare the GenericApplicationContext for the specified application entry point to be used against an ApplicationContextAotGenerator.
      Returns:
      a non-refreshed GenericApplicationContext
    • performAotProcessing

      protected org.springframework.javapoet.ClassName performAotProcessing(GenericApplicationContext applicationContext)
      Perform ahead-of-time processing of the specified context.

      Code, resources, and generated classes are stored in the configured output directories. In addition, run-time hints are registered for the application and its entry point.

      Parameters:
      applicationContext - the context to process
    • createClassNameGenerator

      protected ClassNameGenerator createClassNameGenerator()
      Callback to customize the ClassNameGenerator.

      By default, a standard ClassNameGenerator using the configured application entry point as the default target is used.

      Returns:
      the class name generator
    • getDefaultNativeImageArguments

      protected List<String> getDefaultNativeImageArguments(String applicationClassName)
      Return the native image arguments to use.

      By default, the main class to use, as well as standard application flags are added.

      If the returned list is empty, no native-image.properties is contributed.

      Parameters:
      applicationClassName - the fully qualified class name of the application entry point
      Returns:
      the native image options to contribute