Our Java application is loaded with over 1000 plugins, which are all registered by us as Spring beans using the ApplicationContext # registerBeanDefinition () method. These beans often have other dependencies, which we also register as Spring beans using the same method (a total of about 7000 Spring bean definitions ... not including our main application code).
The problem is that the startup time is long (approximately 6.5 minutes only loading the bean plugin). We would prefer to distribute this loading time over a much longer period, while our application actually processes other requests using plugins that already have their own bean definitions. Most plugins are rarely used. So we would love to lazily register our bean definitions ( this is different from the lazy-init singleton beans, which we already do today ). However, this seems expensive with any existing Spring ApplicationContext that supports refresh () hot calls (as Spring's documentation relates to it).
Spring ApplicationContext classes that support hot-plugging start with the destruction of all singleton beans. Most of our plugins are singletones, so every call to refresh () will destroy most of our plugins and then recreate ... expensive. If we do not call the update, then our recently downloaded beans plugin will not be processed after processing (for example, AOP, etc.).
We can guarantee that when we are forced to download another plugin, we will also load any of its dependencies that are not yet loaded. Thus, we will never encounter a situation when the loaded bean definition is invalid.
, Spring ApplicationContext, "" , bean. bean / BeanFactoryPostProcessors refresh(), !
?. , ?