Class GenericScope
- java.lang.Object
-
- org.springframework.cloud.context.scope.GenericScope
-
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanFactoryPostProcessor,org.springframework.beans.factory.config.Scope,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
- Direct Known Subclasses:
RefreshScope,ThreadScope
public class GenericScope extends Object implements org.springframework.beans.factory.config.Scope, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.beans.factory.DisposableBean
A generic Scope implementation.
- Since:
- 3.1
- Author:
- Dave Syer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGenericScope.LockedScopedProxyFactoryBean<S extends GenericScope>A factory bean with a locked scope.
-
Constructor Summary
Constructors Constructor Description GenericScope()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()protected booleandestroy(String name)Destroys the named bean (i.e.Objectget(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)StringgetConversationId()Map<String,Exception>getErrors()A map of bean name to errors when instantiating the bean.protected ReadWriteLockgetLock(String beanName)protected StringgetName()voidpostProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)voidregisterDestructionCallback(String name, Runnable callback)Objectremove(String name)ObjectresolveContextualObject(String key)voidsetId(String id)Manual override for the serialization ID that will be used to identify the bean factory.voidsetName(String name)The name of this scope.voidsetScopeCache(ScopeCache cache)The cache implementation to use for bean instances in this scope.
-
-
-
Method Detail
-
setId
public void setId(String id)
Manual override for the serialization ID that will be used to identify the bean factory. The default is a unique key based on the bean names in the bean factory.- Parameters:
id- The ID to set.
-
setScopeCache
public void setScopeCache(ScopeCache cache)
The cache implementation to use for bean instances in this scope.- Parameters:
cache- The cache to use.
-
getErrors
public Map<String,Exception> getErrors()
A map of bean name to errors when instantiating the bean.- Returns:
- The errors accumulated since the latest destroy.
-
destroy
public void destroy()
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-
destroy
protected boolean destroy(String name)
Destroys the named bean (i.e. flushes it from the cache by default).- Parameters:
name- The bean name to flush.- Returns:
- True if the bean was already cached; false otherwise.
-
get
public Object get(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)
- Specified by:
getin interfaceorg.springframework.beans.factory.config.Scope
-
getConversationId
public String getConversationId()
- Specified by:
getConversationIdin interfaceorg.springframework.beans.factory.config.Scope
-
registerDestructionCallback
public void registerDestructionCallback(String name, Runnable callback)
- Specified by:
registerDestructionCallbackin interfaceorg.springframework.beans.factory.config.Scope
-
remove
public Object remove(String name)
- Specified by:
removein interfaceorg.springframework.beans.factory.config.Scope
-
resolveContextualObject
public Object resolveContextualObject(String key)
- Specified by:
resolveContextualObjectin interfaceorg.springframework.beans.factory.config.Scope
-
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException- Specified by:
postProcessBeanFactoryin interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor- Throws:
org.springframework.beans.BeansException
-
postProcessBeanDefinitionRegistry
public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException- Specified by:
postProcessBeanDefinitionRegistryin interfaceorg.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor- Throws:
org.springframework.beans.BeansException
-
getName
protected String getName()
-
setName
public void setName(String name)
The name of this scope. Default "generic".- Parameters:
name- The name value to set.
-
getLock
protected ReadWriteLock getLock(String beanName)
-
-