You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bit of context:
I run Micronaut (inject) embedded and the entrypoint is getting a few things, including a path where the config file is located. I load that config file using a standalone config tool (which creates the config if it doesn't exist, updates the config if it's outdated etc.) and returns an instance of a config object. I load the config using the bootstrap context because I also convert them to a PropertySource, which is then used by the 'regular' context for @Requires.
This is where I encounter two issues:
I can't pass data to the bootstrap context:
I've tried using ApplicationContextBuilder#singletons(Object...), ApplicationContext#registerSingleton and ApplicationContext#registerBeanDefinition with the @BootstrapContextCompatible annotation but none seemed to work.
Beans are not passed along to the 'regular' context:
Unlike properties the beans created in the bootstrap context aren't passed along to the 'regular' context, resulting in e.g. the config object bean loaded twice.
This makes me question if it was the correct choice to go with the bootstrap context. Is it the correct choice and are there any alternatives?
As a temporary workaround I have made a static class which acts as a global bean cache. It's basically a map with a computeIfAbsent.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A bit of context:
I run Micronaut (inject) embedded and the entrypoint is getting a few things, including a path where the config file is located. I load that config file using a standalone config tool (which creates the config if it doesn't exist, updates the config if it's outdated etc.) and returns an instance of a config object. I load the config using the bootstrap context because I also convert them to a PropertySource, which is then used by the 'regular' context for
@Requires
.This is where I encounter two issues:
I can't pass data to the bootstrap context:
I've tried using
ApplicationContextBuilder#singletons(Object...)
,ApplicationContext#registerSingleton
andApplicationContext#registerBeanDefinition
with the@BootstrapContextCompatible
annotation but none seemed to work.Beans are not passed along to the 'regular' context:
Unlike properties the beans created in the bootstrap context aren't passed along to the 'regular' context, resulting in e.g. the config object bean loaded twice.
This makes me question if it was the correct choice to go with the bootstrap context. Is it the correct choice and are there any alternatives?
As a temporary workaround I have made a static class which acts as a global bean cache. It's basically a map with a
computeIfAbsent
.Beta Was this translation helpful? Give feedback.
All reactions