Package org.int4.dirk.library
Class SimpleScopeStrategy
- java.lang.Object
-
- org.int4.dirk.library.SimpleScopeStrategy
-
- All Implemented Interfaces:
ScopeStrategy
public class SimpleScopeStrategy extends java.lang.Object implements ScopeStrategy
An implementation ofScopeStrategy.
-
-
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.AnnotationgetDefaultAnnotation()Returns the annotation that marks the default scope.java.lang.annotation.AnnotationgetDependentAnnotation()Returns the annotation that marks the dependent pseudo-scope.java.lang.annotation.AnnotationgetScope(java.lang.reflect.AnnotatedElement element)Returns the scope annotation on the givenAnnotatedElement, if any.java.lang.annotation.AnnotationgetSingletonAnnotation()Returns the annotation that marks the singleton pseudo-scope.booleanisPseudoScope(java.lang.annotation.Annotation annotation)Returns whether the given annotation is a pseudo-scope.
-
-
-
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 annotationClassto use for identifying scope annotations, cannot benulldefaultAnnotation- an annotation which indicates the default scope, cannot benullsingletonAnnotation- an annotation which indicates singletons, cannot benulldependentAnnotation- an annotation which indicates dependent scoped objects, cannot benull
-
-
Method Detail
-
isPseudoScope
public boolean isPseudoScope(java.lang.annotation.Annotation annotation)
Description copied from interface:ScopeStrategyReturns whether the given annotation is a pseudo-scope.- Specified by:
isPseudoScopein interfaceScopeStrategy- Parameters:
annotation- anAnnotation, cannot benull- Returns:
trueif the givenAnnotationis a pseudo-scope, otherwisefalse
-
getDefaultAnnotation
public java.lang.annotation.Annotation getDefaultAnnotation()
Description copied from interface:ScopeStrategyReturns the annotation that marks the default scope. Objects without a scope annotation will get this scope as their scope.- Specified by:
getDefaultAnnotationin interfaceScopeStrategy- Returns:
- an annotation, never
null
-
getDependentAnnotation
public java.lang.annotation.Annotation getDependentAnnotation()
Description copied from interface:ScopeStrategyReturns the annotation that marks the dependent pseudo-scope.- Specified by:
getDependentAnnotationin interfaceScopeStrategy- Returns:
- an annotation, never
null
-
getSingletonAnnotation
public java.lang.annotation.Annotation getSingletonAnnotation()
Description copied from interface:ScopeStrategyReturns the annotation that marks the singleton pseudo-scope.- Specified by:
getSingletonAnnotationin interfaceScopeStrategy- Returns:
- an annotation, never
null
-
getScope
public java.lang.annotation.Annotation getScope(java.lang.reflect.AnnotatedElement element) throws DefinitionExceptionDescription copied from interface:ScopeStrategyReturns the scope annotation on the givenAnnotatedElement, if any. It is recommended to returnnullinstead of a default scope annotation if no scope is found on the given element.- Specified by:
getScopein interfaceScopeStrategy- Parameters:
element- anAnnotatedElement, cannot benull- Returns:
- an annotation, or
nullif the element was not annotated with a scope annotation - Throws:
DefinitionException- when the strategy detects an annotation problem
-
-