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, Yanming Zhou
  • Constructor Details

    • GenericScope

      public GenericScope()
  • Method Details

    • 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:
      destroy in interface org.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:
      get in interface org.springframework.beans.factory.config.Scope
    • getConversationId

      public String getConversationId()
      Specified by:
      getConversationId in interface org.springframework.beans.factory.config.Scope
    • registerDestructionCallback

      public void registerDestructionCallback(String name, Runnable callback)
      Specified by:
      registerDestructionCallback in interface org.springframework.beans.factory.config.Scope
    • remove

      public Object remove(String name)
      Specified by:
      remove in interface org.springframework.beans.factory.config.Scope
    • resolveContextualObject

      public Object resolveContextualObject(String key)
      Specified by:
      resolveContextualObject in interface org.springframework.beans.factory.config.Scope
    • postProcessBeanFactory

      public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Specified by:
      postProcessBeanFactory in interface org.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:
      postProcessBeanDefinitionRegistry in interface org.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)