Interface Scope

  • All Known Implementing Classes:
    ProtoScope, ShutdownAwareScope, SingletonScope, ThreadLocalScope

    public interface Scope
    Petite container bean scope. Scopes actually represents wrapper over none, one or many internal bean pools. Which pool is used depends on scopes behaviour and external data.

    Scopes are instantiated once on their first usage and stored within one container.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean accept​(Scope referenceScope)
      Returns true if a bean of referenced scope can be injected into target bean of this scope.
      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()
      Shutdowns the scope by removing all beans and calling destroy methods.
    • Method Detail

      • lookup

        java.lang.Object lookup​(java.lang.String name)
        Lookups for bean name. Returns null if bean is not found or yet registered.
      • register

        void register​(BeanDefinition beanDefinition,
                      java.lang.Object bean)
        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.
      • remove

        void remove​(java.lang.String name)
        Removes the bean from the scope entirely. Destroy methods are not called as it is assumed that bean is destroyed manually.
      • accept

        boolean accept​(Scope referenceScope)
        Returns true if a bean of referenced scope can be injected into target bean of this scope. Otherwise, returns false, which may be a sign for scoped proxy to be injected.

        In general, injection of 'shorter' reference scopes into the 'longer' target scopes should not be accepted. In other words, if reference scope is 'longer' or equal (same), this method should return true.

        Helpful is to ask the following question: "May the reference scope bean be injected into bean of this scope?".

      • shutdown

        void shutdown()
        Shutdowns the scope by removing all beans and calling destroy methods.