|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConfigurableBeanFactory
Configuration interface to be implemented by most bean factories. Provides
facilities to configure a bean factory, in addition to the bean factory
client methods in the BeanFactory
interface.
This bean factory interface is not meant to be used in normal application
code: Stick to BeanFactory
or
ListableBeanFactory
for typical
needs. This extended interface is just meant to allow for framework-internal
plug'n'play and for special access to bean factory configuration methods.
BeanFactory
,
ListableBeanFactory
,
ConfigurableListableBeanFactory
Field Summary | |
---|---|
static String |
SCOPE_PROTOTYPE
Scope identifier for the standard prototype scope: "prototype". |
static String |
SCOPE_SINGLETON
Scope identifier for the standard singleton scope: "singleton". |
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
---|
FACTORY_BEAN_PREFIX |
Method Summary | |
---|---|
void |
addBeanPostProcessor(BeanPostProcessor beanPostProcessor)
Add a new BeanPostProcessor that will get applied to beans created by this factory. |
void |
addEmbeddedValueResolver(StringValueResolver valueResolver)
Add a String resolver for embedded values such as annotation attributes. |
void |
addPropertyEditorRegistrar(PropertyEditorRegistrar registrar)
Add a PropertyEditorRegistrar to be applied to all bean creation processes. |
void |
copyConfigurationFrom(ConfigurableBeanFactory otherFactory)
Copy all relevant configuration from the given other factory. |
void |
copyRegisteredEditorsTo(PropertyEditorRegistry registry)
Initialize the given PropertyEditorRegistry with the custom editors that have been registered with this BeanFactory. |
void |
destroyBean(String beanName,
Object beanInstance)
Destroy the given bean instance (usually a prototype instance obtained from this factory) according to its bean definition. |
void |
destroyScopedBean(String beanName)
Destroy the specified scoped bean in the current target scope, if any. |
void |
destroySingletons()
Destroy all singleton beans in this factory, including inner beans that have been registered as disposable. |
AccessControlContext |
getAccessControlContext()
Provides a security access control context relevant to this factory. |
ClassLoader |
getBeanClassLoader()
Return this factory's class loader for loading bean classes. |
BeanExpressionResolver |
getBeanExpressionResolver()
Return the resolution strategy for expressions in bean definition values. |
int |
getBeanPostProcessorCount()
Return the current number of registered BeanPostProcessors, if any. |
ConversionService |
getConversionService()
Return the associated ConversionService, if any. |
String[] |
getDependenciesForBean(String beanName)
Return the names of all beans that the specified bean depends on, if any. |
String[] |
getDependentBeans(String beanName)
Return the names of all beans which depend on the specified bean, if any. |
BeanDefinition |
getMergedBeanDefinition(String beanName)
Return a merged BeanDefinition for the given bean name, merging a child bean definition with its parent if necessary. |
Scope |
getRegisteredScope(String scopeName)
Return the Scope implementation for the given scope name, if any. |
String[] |
getRegisteredScopeNames()
Return the names of all currently registered scopes. |
ClassLoader |
getTempClassLoader()
Return the temporary ClassLoader to use for type matching purposes, if any. |
TypeConverter |
getTypeConverter()
Obtain a type converter as used by this BeanFactory. |
boolean |
isCacheBeanMetadata()
Return whether to cache bean metadata such as given bean definitions (in merged fashion) and resolved bean classes. |
boolean |
isCurrentlyInCreation(String beanName)
Determine whether the specified bean is currently in creation. |
boolean |
isFactoryBean(String name)
Determine whether the bean with the given name is a FactoryBean. |
void |
registerAlias(String beanName,
String alias)
Given a bean name, create an alias. |
void |
registerCustomEditor(Class<?> requiredType,
Class<? extends PropertyEditor> propertyEditorClass)
Register the given custom property editor for all properties of the given type. |
void |
registerDependentBean(String beanName,
String dependentBeanName)
Register a dependent bean for the given bean, to be destroyed before the given bean is destroyed. |
void |
registerScope(String scopeName,
Scope scope)
Register the given scope, backed by the given Scope implementation. |
void |
resolveAliases(StringValueResolver valueResolver)
Resolve all alias target names and aliases registered in this factory, applying the given StringValueResolver to them. |
String |
resolveEmbeddedValue(String value)
Resolve the given embedded value, e.g. |
void |
setBeanClassLoader(ClassLoader beanClassLoader)
Set the class loader to use for loading bean classes. |
void |
setBeanExpressionResolver(BeanExpressionResolver resolver)
Specify the resolution strategy for expressions in bean definition values. |
void |
setCacheBeanMetadata(boolean cacheBeanMetadata)
Set whether to cache bean metadata such as given bean definitions (in merged fashion) and resolved bean classes. |
void |
setConversionService(ConversionService conversionService)
Specify a Spring 3.0 ConversionService to use for converting property values, as an alternative to JavaBeans PropertyEditors. |
void |
setCurrentlyInCreation(String beanName,
boolean inCreation)
Explicitly control in-creation status of the specified bean. |
void |
setParentBeanFactory(BeanFactory parentBeanFactory)
Set the parent of this bean factory. |
void |
setTempClassLoader(ClassLoader tempClassLoader)
Specify a temporary ClassLoader to use for type matching purposes. |
void |
setTypeConverter(TypeConverter typeConverter)
Set a custom type converter that this BeanFactory should use for converting bean property values, constructor argument values, etc. |
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory |
---|
containsLocalBean, getParentBeanFactory |
Methods inherited from interface org.springframework.beans.factory.BeanFactory |
---|
containsBean, getAliases, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch |
Methods inherited from interface org.springframework.beans.factory.config.SingletonBeanRegistry |
---|
containsSingleton, getSingleton, getSingletonCount, getSingletonNames, registerSingleton |
Field Detail |
---|
static final String SCOPE_SINGLETON
registerScope
.
registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)
,
Constant Field Valuesstatic final String SCOPE_PROTOTYPE
registerScope
.
registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)
,
Constant Field ValuesMethod Detail |
---|
void setParentBeanFactory(BeanFactory parentBeanFactory) throws IllegalStateException
Note that the parent cannot be changed: It should only be set outside a constructor if it isn't available at the time of factory instantiation.
parentBeanFactory
- the parent BeanFactory
IllegalStateException
- if this factory is already associated with
a parent BeanFactoryHierarchicalBeanFactory.getParentBeanFactory()
void setBeanClassLoader(ClassLoader beanClassLoader)
Note that this class loader will only apply to bean definitions that do not carry a resolved bean class yet. This is the case as of Spring 2.0 by default: Bean definitions only carry bean class names, to be resolved once the factory processes the bean definition.
beanClassLoader
- the class loader to use,
or null
to suggest the default class loaderClassLoader getBeanClassLoader()
void setTempClassLoader(ClassLoader tempClassLoader)
A temporary ClassLoader is usually just specified if load-time weaving is involved, to make sure that actual bean classes are loaded as lazily as possible. The temporary loader is then removed once the BeanFactory completes its bootstrap phase.
ClassLoader getTempClassLoader()
void setCacheBeanMetadata(boolean cacheBeanMetadata)
Turn this flag off to enable hot-refreshing of bean definition objects and in particular bean classes. If this flag is off, any creation of a bean instance will re-query the bean class loader for newly resolved classes.
boolean isCacheBeanMetadata()
void setBeanExpressionResolver(BeanExpressionResolver resolver)
There is no expression support active in a BeanFactory by default. An ApplicationContext will typically set a standard expression strategy here, supporting "#{...}" expressions in a Unified EL compatible style.
BeanExpressionResolver getBeanExpressionResolver()
void setConversionService(ConversionService conversionService)
ConversionService getConversionService()
void addPropertyEditorRegistrar(PropertyEditorRegistrar registrar)
Such a registrar creates new PropertyEditor instances and registers them
on the given registry, fresh for each bean creation attempt. This avoids
the need for synchronization on custom editors; hence, it is generally
preferable to use this method instead of registerCustomEditor(java.lang.Class>, java.lang.Class extends java.beans.PropertyEditor>)
.
registrar
- the PropertyEditorRegistrar to registervoid registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass)
Note that this method will register a shared custom editor instance;
access to that instance will be synchronized for thread-safety. It is
generally preferable to use addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar)
instead
of this method, to avoid for the need for synchronization on custom editors.
requiredType
- type of the propertypropertyEditorClass
- the PropertyEditor
class to registervoid copyRegisteredEditorsTo(PropertyEditorRegistry registry)
registry
- the PropertyEditorRegistry to initializevoid setTypeConverter(TypeConverter typeConverter)
This will override the default PropertyEditor mechanism and hence make any custom editors or custom editor registrars irrelevant.
addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar)
,
registerCustomEditor(java.lang.Class>, java.lang.Class extends java.beans.PropertyEditor>)
TypeConverter getTypeConverter()
If the default PropertyEditor mechanism is active, the returned TypeConverter will be aware of all custom editors that have been registered.
void addEmbeddedValueResolver(StringValueResolver valueResolver)
valueResolver
- the String resolver to apply to embedded valuesString resolveEmbeddedValue(String value)
value
- the value to resolve
void addBeanPostProcessor(BeanPostProcessor beanPostProcessor)
Note: Post-processors submitted here will be applied in the order of
registration; any ordering semantics expressed through implementing the
Ordered
interface will be ignored. Note
that autodetected post-processors (e.g. as beans in an ApplicationContext)
will always be applied after programmatically registered ones.
beanPostProcessor
- the post-processor to registerint getBeanPostProcessorCount()
void registerScope(String scopeName, Scope scope)
scopeName
- the scope identifierscope
- the backing Scope implementationString[] getRegisteredScopeNames()
This will only return the names of explicitly registered scopes. Built-in scopes such as "singleton" and "prototype" won't be exposed.
registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)
Scope getRegisteredScope(String scopeName)
This will only return explicitly registered scopes. Built-in scopes such as "singleton" and "prototype" won't be exposed.
scopeName
- the name of the scope
null
if noneregisterScope(java.lang.String, org.springframework.beans.factory.config.Scope)
AccessControlContext getAccessControlContext()
null
)void copyConfigurationFrom(ConfigurableBeanFactory otherFactory)
Should include all standard configuration settings as well as BeanPostProcessors, Scopes, and factory-specific internal settings. Should not include any metadata of actual bean definitions, such as BeanDefinition objects and bean name aliases.
otherFactory
- the other BeanFactory to copy fromvoid registerAlias(String beanName, String alias) throws BeanDefinitionStoreException
Typically invoked during factory configuration, but can also be used for runtime registration of aliases. Therefore, a factory implementation should synchronize alias access.
beanName
- the canonical name of the target beanalias
- the alias to be registered for the bean
BeanDefinitionStoreException
- if the alias is already in usevoid resolveAliases(StringValueResolver valueResolver)
The value resolver may for example resolve placeholders in target bean names and even in alias names.
valueResolver
- the StringValueResolver to applyBeanDefinition getMergedBeanDefinition(String beanName) throws NoSuchBeanDefinitionException
beanName
- the name of the bean to retrieve the merged definition for
NoSuchBeanDefinitionException
- if there is no bean definition with the given nameboolean isFactoryBean(String name) throws NoSuchBeanDefinitionException
name
- the name of the bean to check
false
means the bean exists but is not a FactoryBean)
NoSuchBeanDefinitionException
- if there is no bean with the given namevoid setCurrentlyInCreation(String beanName, boolean inCreation)
beanName
- the name of the beaninCreation
- whether the bean is currently in creationboolean isCurrentlyInCreation(String beanName)
beanName
- the name of the bean
void registerDependentBean(String beanName, String dependentBeanName)
beanName
- the name of the beandependentBeanName
- the name of the dependent beanString[] getDependentBeans(String beanName)
beanName
- the name of the bean
String[] getDependenciesForBean(String beanName)
beanName
- the name of the bean
void destroyBean(String beanName, Object beanInstance)
Any exception that arises during destruction should be caught and logged instead of propagated to the caller of this method.
beanName
- the name of the bean definitionbeanInstance
- the bean instance to destroyvoid destroyScopedBean(String beanName)
Any exception that arises during destruction should be caught and logged instead of propagated to the caller of this method.
beanName
- the name of the scoped beanvoid destroySingletons()
Any exception that arises during destruction should be caught and logged instead of propagated to the caller of this method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |