Class SimpleScopeStrategy

    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleScopeStrategy​(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotationClass, java.lang.annotation.Annotation defaultAnnotation, java.lang.annotation.Annotation singletonAnnotation, java.lang.annotation.Annotation dependentAnnotation)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.annotation.Annotation getDefaultAnnotation()
      Returns the annotation that marks the default scope.
      java.lang.annotation.Annotation getDependentAnnotation()
      Returns the annotation that marks the dependent pseudo-scope.
      java.lang.annotation.Annotation getScope​(java.lang.reflect.AnnotatedElement element)
      Returns the scope annotation on the given AnnotatedElement, if any.
      java.lang.annotation.Annotation getSingletonAnnotation()
      Returns the annotation that marks the singleton pseudo-scope.
      boolean isPseudoScope​(java.lang.annotation.Annotation annotation)
      Returns whether the given annotation is a pseudo-scope.
      • Methods inherited from class java.lang.Object

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

      • SimpleScopeStrategy

        public SimpleScopeStrategy​(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotationClass,
                                   java.lang.annotation.Annotation defaultAnnotation,
                                   java.lang.annotation.Annotation singletonAnnotation,
                                   java.lang.annotation.Annotation dependentAnnotation)
        Constructs a new instance.
        Parameters:
        scopeAnnotationClass - an annotation Class to use for identifying scope annotations, cannot be null
        defaultAnnotation - an annotation which indicates the default scope, cannot be null
        singletonAnnotation - an annotation which indicates singletons, cannot be null
        dependentAnnotation - an annotation which indicates dependent scoped objects, cannot be null
    • Method Detail

      • isPseudoScope

        public boolean isPseudoScope​(java.lang.annotation.Annotation annotation)
        Description copied from interface: ScopeStrategy
        Returns whether the given annotation is a pseudo-scope.
        Specified by:
        isPseudoScope in interface ScopeStrategy
        Parameters:
        annotation - an Annotation, cannot be null
        Returns:
        true if the given Annotation is a pseudo-scope, otherwise false
      • getDefaultAnnotation

        public java.lang.annotation.Annotation getDefaultAnnotation()
        Description copied from interface: ScopeStrategy
        Returns the annotation that marks the default scope. Objects without a scope annotation will get this scope as their scope.
        Specified by:
        getDefaultAnnotation in interface ScopeStrategy
        Returns:
        an annotation, never null
      • getDependentAnnotation

        public java.lang.annotation.Annotation getDependentAnnotation()
        Description copied from interface: ScopeStrategy
        Returns the annotation that marks the dependent pseudo-scope.
        Specified by:
        getDependentAnnotation in interface ScopeStrategy
        Returns:
        an annotation, never null
      • getSingletonAnnotation

        public java.lang.annotation.Annotation getSingletonAnnotation()
        Description copied from interface: ScopeStrategy
        Returns the annotation that marks the singleton pseudo-scope.
        Specified by:
        getSingletonAnnotation in interface ScopeStrategy
        Returns:
        an annotation, never null
      • getScope

        public java.lang.annotation.Annotation getScope​(java.lang.reflect.AnnotatedElement element)
                                                 throws DefinitionException
        Description copied from interface: ScopeStrategy
        Returns the scope annotation on the given AnnotatedElement, if any. It is recommended to return null instead of a default scope annotation if no scope is found on the given element.
        Specified by:
        getScope in interface ScopeStrategy
        Parameters:
        element - an AnnotatedElement, cannot be null
        Returns:
        an annotation, or null if the element was not annotated with a scope annotation
        Throws:
        DefinitionException - when the strategy detects an annotation problem