Package org.springframework.guice.module
Class BeanFactoryProvider
java.lang.Object
org.springframework.guice.module.BeanFactoryProvider
- All Implemented Interfaces:
jakarta.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>,Closeable,AutoCloseable
public class BeanFactoryProvider
extends Object
implements jakarta.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>, Closeable
A Provider for a BeanFactory from an ApplicationContext that
will not be refreshed until the Guice injector wants to resolve dependencies. Delaying
the refresh means that the bean factory can resolve dependencies from Guice modules
(and vice versa).
Also implements Closeable so if you want to clean up resources used in the
application context then you can keep a reference to the provider and call
close() on it when the application is shut down. Alternatively, you could
register an ApplicationContextInitializer that sets a shutdown hook, so that
the context is closed automatically when the JVM ends.
- Author:
- Dave Syer
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static BeanFactoryProviderCreate an application context using these configuration classes.static BeanFactoryProviderCreate an application context by scanning these base packages.org.springframework.beans.factory.config.ConfigurableListableBeanFactoryget()initializer(org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>... initializers)
-
Method Details
-
from
Create an application context by scanning these base packages.- Parameters:
basePackages- base packages to scan- Returns:
- a provider
-
from
Create an application context using these configuration classes.- Parameters:
config- classes to build an application- Returns:
- a provider
-
initializer
public BeanFactoryProvider initializer(org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>... initializers) -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
get
public org.springframework.beans.factory.config.ConfigurableListableBeanFactory get()- Specified by:
getin interfacejakarta.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>
-