public Class<? extends Annotation> scope() { if (null == scope) { synchronized (this) { if (null == scope) { Class<?> c = getClass(); if (c.isAnnotationPresent(RequestScoped.class)) { scope = RequestScoped.class; } else if (c.isAnnotationPresent(SessionScoped.class)) { scope = SessionScoped.class; } else if (c.isAnnotationPresent(ApplicationScoped.class)) { scope = ApplicationScoped.class; } else { scope = NormalScope.class; } } } } return scope; }
/** * Activate and deactivate contexts for the given normal scopes for each test method execution. * <p> * {@link ApplicationScoped} is ignored as it is always active. * </p> * * @param normalScopes * @return self */ @SafeVarargs public final T activate(Class<? extends Annotation>... normalScopes) { for (Class<? extends Annotation> scope : normalScopes) { if (ApplicationScoped.class.equals(scope)) { continue; } if (!scope.isAnnotationPresent(NormalScope.class)) { throw new IllegalArgumentException("Only annotations annotated with @NormalScope are supported!"); } this.scopesToActivate.add(scope); } return self(); }