Class SingletonScope

  • All Implemented Interfaces:
    Scope

    public class SingletonScope
    extends java.lang.Object
    implements Scope
    Singleton scope pools all bean instances so they will be created only once in the container context.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​BeanData> instances  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(Scope referenceScope)
      Allows only singleton scoped beans to be injected into the target singleton bean.
      java.lang.Object lookup​(java.lang.String name)
      Lookups for bean name.
      void register​(BeanDefinition beanDefinition, java.lang.Object bean)
      Registers the bean within the current scope.
      void remove​(java.lang.String name)
      Removes the bean from the scope entirely.
      void shutdown()
      Iterate all beans and invokes registered destroy methods.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • instances

        protected java.util.Map<java.lang.String,​BeanData> instances
    • Method Detail

      • lookup

        public java.lang.Object lookup​(java.lang.String name)
        Description copied from interface: Scope
        Lookups for bean name. Returns null if bean is not found or yet registered.
        Specified by:
        lookup in interface Scope
      • register

        public void register​(BeanDefinition beanDefinition,
                             java.lang.Object bean)
        Description copied from interface: Scope
        Registers the bean within the current scope. Usually registers it by its name from BeanDefinition. Also it may register destroy methods of a bean within this scope.
        Specified by:
        register in interface Scope
      • remove

        public void remove​(java.lang.String name)
        Description copied from interface: Scope
        Removes the bean from the scope entirely. Destroy methods are not called as it is assumed that bean is destroyed manually.
        Specified by:
        remove in interface Scope
      • accept

        public boolean accept​(Scope referenceScope)
        Allows only singleton scoped beans to be injected into the target singleton bean.
        Specified by:
        accept in interface Scope
      • shutdown

        public void shutdown()
        Iterate all beans and invokes registered destroy methods.
        Specified by:
        shutdown in interface Scope