Package org.springframework.guice.module
Class BeanFactoryProvider
- java.lang.Object
-
- org.springframework.guice.module.BeanFactoryProvider
-
- All Implemented Interfaces:
Closeable,AutoCloseable,javax.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>
public class BeanFactoryProvider extends Object implements javax.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>, Closeable
A
Providerfor aBeanFactoryfrom anApplicationContextthat 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
Closeableso if you want to clean up resources used in the application context then you can keep a reference to the provider and callclose()on it when the application is shut down. Alternatively, you could register anApplicationContextInitializerthat sets a shutdown hook, so that the context is closed automatically when the JVM ends.- Author:
- Dave Syer
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static BeanFactoryProviderfrom(Class<?>... config)Create an application context using these configuration classes.static BeanFactoryProviderfrom(String... basePackages)Create an application context by scanning these base packages.org.springframework.beans.factory.config.ConfigurableListableBeanFactoryget()BeanFactoryProviderinitializer(org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>... initializers)
-
-
-
Method Detail
-
from
public static BeanFactoryProvider from(String... basePackages)
Create an application context by scanning these base packages.- Parameters:
basePackages- base packages to scan- Returns:
- a provider
-
from
public static BeanFactoryProvider from(Class<?>... config)
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
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
get
public org.springframework.beans.factory.config.ConfigurableListableBeanFactory get()
- Specified by:
getin interfacejavax.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>
-
-