Top Description Fields Constructors Methods
org.springframework.beans.factory.config

public Class CustomScopeConfigurer

extends Object
implements BeanFactoryPostProcessor, BeanClassLoaderAware, Ordered
Class Inheritance
All Implemented Interfaces
org.springframework.core.Ordered, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanFactoryPostProcessor
Imports
java.util.LinkedHashMap, .Map, org.springframework.beans.BeanUtils, .BeansException, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.core.Ordered, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils

Simple BeanFactoryPostProcessor implementation that registers custom Scope(s) with the containing ConfigurableBeanFactory.

Will register all of the supplied scopes with the ConfigurableListableBeanFactory that is passed to the postProcessBeanFactory(ConfigurableListableBeanFactory) method.

This class allows for declarative registration of custom scopes. Alternatively, consider implementing a custom BeanFactoryPostProcessor that calls ConfigurableBeanFactory#registerScope programmatically.

Authors
Juergen Hoeller, Rick Evans
Since
2.0
See Also
ConfigurableBeanFactory#registerScope

Field Summary

Modifier and TypeField and Description
private ClassLoader
private int
private Map<String, Object>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addScope(String
the name of the scope
scopeName
,
Scope
the scope implementation
scope
)

Add the given scope to this configurer's map of scopes.

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.

public void
postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context
beanFactory
)

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Modify the application context's internal bean factory after its standard initialization.

public void
setBeanClassLoader(ClassLoader
the owning class loader
beanClassLoader
)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

public void
setOrder(int order)

public void
setScopes(Map<String, Object> scopes)

Specify the custom scopes that are to be registered.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanClassLoaderback to summary
private ClassLoader beanClassLoader
Annotations
@Nullable
orderback to summary
private int order
scopesback to summary
private Map<String, Object> scopes
Annotations
@Nullable

Constructor Detail

CustomScopeConfigurerback to summary
public CustomScopeConfigurer()

Method Detail

addScopeback to summary
public void addScope(String scopeName, Scope scope)

Add the given scope to this configurer's map of scopes.

Parameters
scopeName:String

the name of the scope

scope:Scope

the scope implementation

Since
4.1.1
getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

Get the order value of this object.

Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startup values).

Same order values will result in arbitrary sort positions for the affected objects.

Returns:int

the order value

Annotations
@Override
postProcessBeanFactoryback to summary
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Doc from org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.

Parameters
beanFactory:ConfigurableListableBeanFactory

the bean factory used by the application context

Annotations
@Override
Exceptions
BeansException:
in case of errors
setBeanClassLoaderback to summary
public void setBeanClassLoader(ClassLoader beanClassLoader)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Doc from org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean#afterPropertiesSet() method or a custom init-method.

Parameters
beanClassLoader:ClassLoader

the owning class loader

Annotations
@Override
setOrderback to summary
public void setOrder(int order)
setScopesback to summary
public void setScopes(Map<String, Object> scopes)

Specify the custom scopes that are to be registered.

The keys indicate the scope names (of type String); each value is expected to be the corresponding custom Scope instance or class name.