Class DynamicSingletonProvider

  • All Implemented Interfaces:
    com.google.inject.Provider<java.lang.Object>, javax.inject.Provider<java.lang.Object>

    public class DynamicSingletonProvider
    extends DynamicClassProvider
    Specific version of DynamicClassProvider, which applies singleton scope to generated classes. The main intention is to reduce code size from common case from @ScopeAnnotation(Singleton.class) @ProvidedBy(DynamicClassProvider.class) to simply @ProvidedBy(DynamicSingletonProvider.class).

    If used with injectors hierarchy or within private modules, use together with GeneratorAnchorModule to properly scope dynamic bindings.

    Since:
    05.01.2015
    See Also:
    for more docs
    • Constructor Summary

      Constructors 
      Constructor Description
      DynamicSingletonProvider​(com.google.inject.Injector injector)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
      Override it to specify different annotation.
      • Methods inherited from class java.lang.Object

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

      • DynamicSingletonProvider

        @Inject
        public DynamicSingletonProvider​(com.google.inject.Injector injector)
    • Method Detail

      • getScopeAnnotation

        protected java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
        Description copied from class: DynamicClassProvider
        Override it to specify different annotation. By default, no annotation specified which will implicitly lead to default prototype scope.
        Overrides:
        getScopeAnnotation in class DynamicClassProvider
        Returns:
        scope annotation which should be applied to generated class