Class SingletonScope

java.lang.Object
be.imgn.inject.context.SingletonScope
All Implemented Interfaces:
Scope

public final class SingletonScope extends Object implements Scope
The built-in Singleton scope: memoizes the wrapped provider.
  • Constructor Details

    • SingletonScope

      public SingletonScope()
      Creates the scope. Instantiated by ServiceLoader.
  • Method Details

    • annotationType

      public Class<? extends Annotation> annotationType()
      Description copied from interface: Scope
      Returns the scoping annotation this scope handles.
      Specified by:
      annotationType in interface Scope
      Returns:
      the scoping annotation this scope handles
    • wrap

      public <T> Provider<T> wrap(Provider<T> provider)
      Description copied from interface: Scope
      Returns provider wrapped with this scope's lifecycle.
      Specified by:
      wrap in interface Scope
      Type Parameters:
      T - the provided type
      Parameters:
      provider - the unscoped provider
      Returns:
      provider wrapped with this scope's lifecycle