public class BeanFactoryProvider extends Object implements javax.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.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static BeanFactoryProvider |
from(Class<?>... config)
Create an application context using these configuration classes.
|
static BeanFactoryProvider |
from(String... basePackages)
Create an application context by scanning these base packages.
|
org.springframework.beans.factory.config.ConfigurableListableBeanFactory |
get() |
BeanFactoryProvider |
initializer(org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>... initializers) |
public static BeanFactoryProvider from(String... basePackages)
basePackages - base packages to scanpublic static BeanFactoryProvider from(Class<?>... config)
config - classes to build an applicationpublic BeanFactoryProvider initializer(org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>... initializers)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic org.springframework.beans.factory.config.ConfigurableListableBeanFactory get()
get in interface javax.inject.Provider<org.springframework.beans.factory.config.ConfigurableListableBeanFactory>Copyright © 2018 Pivotal Software, Inc.. All rights reserved.