Class PythonRuntimeBootstrapConfigurer

java.lang.Object
io.micronaut.context.python.PythonRuntimeBootstrapConfigurer
All Implemented Interfaces:
ApplicationContextConfigurer, Ordered

@Internal @ContextConfigurer public final class PythonRuntimeBootstrapConfigurer extends Object implements ApplicationContextConfigurer
Records the application context that is starting, so generated Python code that runs before the @Context GraalPy context bean is initialized can create that bean on demand.

Type converters are created before the eager beans, and the beans of processOnStartup executable methods (message listeners, scheduled jobs, ...) are instantiated by their processors before the eager beans too. A Python bean created that early needs the runtime; with the context recorded here, PythonContextRuntime creates the GraalPy context bean of this application instead of failing because the bean does not exist yet. The record is cleared when the application context shuts down (see PythonRuntimeBootstrapShutdownListener).

The bootstrap context of an application (see BootstrapContextAccess) runs the configurer too but is never recorded: it only holds BootstrapContextCompatible beans, so it cannot provide the GraalPy context bean, and it publishes no ShutdownEvent that would clear the record again, which matters when a refresh recreates it while the application is running.

Since:
5.3.0
Author:
Micronaut Team
  • Constructor Details

    • PythonRuntimeBootstrapConfigurer

      public PythonRuntimeBootstrapConfigurer()
  • Method Details