Top Description Fields Constructors Methods
org.springframework.context.aot

public abstract Class ContextAotProcessor

extends AbstractAotProcessor<ClassName>
Class Inheritance
Imports
java.io.IOException, java.nio.file.Files, .Path, java.util.ArrayList, .Collections, .List, org.springframework.aot.generate.ClassNameGenerator, .DefaultGenerationContext, .FileSystemGeneratedFiles, org.springframework.aot.hint.ExecutableMode, .ReflectionHints, .TypeReference, org.springframework.context.support.GenericApplicationContext, org.springframework.javapoet.ClassName, org.springframework.util.CollectionUtils

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.

Authors
Stephane Nicoll, Andy Wilkinson, Phillip Webb, Sam Brannen
Since
6.0
See Also
org.springframework.test.context.aot.TestAotProcessor

Field Summary

Modifier and TypeField and Description
private final Class<?>

Constructor Summary

AccessConstructor and Description
protected
ContextAotProcessor(Class<?>
the application entry point (class with a main() method)
applicationClass
,
AbstractAotProcessor.Settings
the settings to apply
settings
)

Create a new processor for the specified application entry point and common settings.

Method Summary

Modifier and TypeMethod and Description
protected ClassNameGenerator

Returns:

the class name generator
createClassNameGenerator
()

Callback to customize the ClassNameGenerator.

protected ClassName

Returns:

the ClassName of the ApplicationContextInitializer entry point
doProcess
()

Implements abstract org.springframework.context.aot.AbstractAotProcessor.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>

Returns:

the native image options to contribute
getDefaultNativeImageArguments
(String
the fully qualified class name of the application entry point
applicationClassName
)

Return the native image arguments to use.

protected ClassName
performAotProcessing(GenericApplicationContext
the context to process
applicationContext
)

Perform ahead-of-time processing of the specified context.

protected abstract GenericApplicationContext

Returns:

a non-refreshed GenericApplicationContext
prepareApplicationContext
(Class<?> applicationClass)

Prepare the GenericApplicationContext for the specified application entry point to be used against an ApplicationContextAotGenerator.

private void
registerEntryPointHint(DefaultGenerationContext generationContext, ClassName generatedInitializerClassName)

private void
Inherited from org.springframework.context.aot.AbstractAotProcessor:
createFileSystemGeneratedFilesdeleteExistingOutputgetSettingsprocesswriteHints

Field Detail

applicationClassback to summary
private final Class<?> applicationClass

Constructor Detail

ContextAotProcessorback to summary
protected ContextAotProcessor(Class<?> applicationClass, AbstractAotProcessor.Settings settings)

Create a new processor for the specified application entry point and common settings.

Parameters
applicationClass:Class<?>

the application entry point (class with a main() method)

settings:AbstractAotProcessor.Settings

the settings to apply

Method Detail

createClassNameGeneratorback to summary
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:ClassNameGenerator

the class name generator

doProcessback to summary
protected ClassName doProcess()

Implements abstract org.springframework.context.aot.AbstractAotProcessor.doProcess.

Invoke the processing by clearing output directories first, followed by performAotProcessing(GenericApplicationContext).

Returns:ClassName

the ClassName of the ApplicationContextInitializer entry point

Annotations
@Override
getApplicationClassback to summary
protected Class<?> getApplicationClass()

Get the application entry point (typically a class with a main() method).

getDefaultNativeImageArgumentsback to summary
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:String

the fully qualified class name of the application entry point

Returns:List<String>

the native image options to contribute

performAotProcessingback to summary
protected 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:GenericApplicationContext

the context to process

prepareApplicationContextback to summary
protected abstract GenericApplicationContext prepareApplicationContext(Class<?> applicationClass)

Prepare the GenericApplicationContext for the specified application entry point to be used against an ApplicationContextAotGenerator.

Returns:GenericApplicationContext

a non-refreshed GenericApplicationContext

registerEntryPointHintback to summary
private void registerEntryPointHint(DefaultGenerationContext generationContext, ClassName generatedInitializerClassName)
writeNativeImagePropertiesback to summary
private void writeNativeImageProperties(List<String> args)