Package org.springframework.context.aot

# Class ContextAotProcessor

java.lang.Object
org.springframework.context.aot.AbstractAotProcessor<org.springframework.javapoet.ClassName>
org.springframework.context.aot.ContextAotProcessor

public abstract class ContextAotProcessor extends AbstractAotProcessor<org.springframework.javapoet.ClassName>
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:
  - `org.springframework.test.context.aot.TestAotProcessor`

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.context.aot.AbstractAotProcessor

`AbstractAotProcessor.Settings`

## Field Summary

### Fields inherited from class org.springframework.context.aot.AbstractAotProcessor

`AOT_PROCESSING`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`ContextAotProcessor(Class<?> applicationClass, AbstractAotProcessor.Settings settings)`
Create a new processor for the specified application entry point and common settings.

## Method Summary

Modifier and Type
Method
Description
`protected org.springframework.aot.generate.ClassNameGenerator`
`createClassNameGenerator()`
Callback to customize the `ClassNameGenerator`.
`protected org.springframework.javapoet.ClassName`
`doProcess()`
Invoke the processing by clearing output directories first, followed by `performAotProcessing(GenericApplicationContext)`.
`protected Class<?>`
`getApplicationClass()`
Get the application entry point (typically a class with a `main()` method).
`protected List<String>`
`getDefaultNativeImageArguments(String applicationClassName)`
Return the native image arguments to use.
`protected org.springframework.javapoet.ClassName`
`performAotProcessing(GenericApplicationContext applicationContext)`
Perform ahead-of-time processing of the specified context.
`protected abstract GenericApplicationContext`
`prepareApplicationContext(Class<?> applicationClass)`
Prepare the `GenericApplicationContext` for the specified application entry point to be used against an `ApplicationContextAotGenerator`.

### Methods inherited from class org.springframework.context.aot.AbstractAotProcessor

`createFileSystemGeneratedFiles, deleteExistingOutput, getSettings, process, writeHints`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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 application entry point (typically a class with a `main()` method).

### doProcess

protected org.springframework.javapoet.ClassName doProcess()
Invoke the processing by clearing output directories first, followed by `performAotProcessing(GenericApplicationContext)`.

Specified by:
  `doProcess` in class `AbstractAotProcessor<org.springframework.javapoet.ClassName>`
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 org.springframework.aot.generate.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