private static List<Annotation> getBindings(Annotation[] annotations, BeanManager beanManager) { if (annotations.length == 0) { return Collections.emptyList(); } List<Annotation> bindings = new ArrayList<>(); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { bindings.add(annotation); } } return bindings; }
private static List<Annotation> getBindings(Set<Annotation> annotations, BeanManager beanManager) { if (annotations == null || annotations.size() == 0) { return Collections.emptyList(); } List<Annotation> bindings = new ArrayList<>(); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { bindings.add(annotation); } } return bindings; }
private static List<Annotation> getBindings(Annotation[] annotations, BeanManager beanManager) { if (annotations.length == 0) { return Collections.emptyList(); } List<Annotation> bindings = new ArrayList<>(); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { bindings.add(annotation); } } return bindings; }
private static List<Annotation> getBindings(Set<Annotation> annotations, BeanManager beanManager) { if (annotations == null || annotations.size() == 0) { return Collections.emptyList(); } List<Annotation> bindings = new ArrayList<>(); for (Annotation annotation : annotations) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { bindings.add(annotation); } } return bindings; }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Override public boolean isInterceptorBinding(Class<? extends Annotation> annotationType) { return delegate().isInterceptorBinding(annotationType); }
@Test @SpecAssertion(section = BM_DETERMINING_ANNOTATION, id = "ad") public void testDetermineInterceptorBindingType() { assertTrue(getCurrentManager().isInterceptorBinding(Transactional.class)); assertFalse(getCurrentManager().isInterceptorBinding(Tame.class)); assertFalse(getCurrentManager().isInterceptorBinding(AnimalStereotype.class)); assertFalse(getCurrentManager().isInterceptorBinding(ApplicationScoped.class)); }
@Test(groups="rewrite") // WBRI-59 // Should also check a custom interceptor binding type @SpecAssertion(section = "11.3.13", id = "ad") public void testDetermineInterceptorBindingType() { assert getCurrentManager().isInterceptorBinding(Transactional.class); assert !getCurrentManager().isInterceptorBinding(Tame.class); assert !getCurrentManager().isInterceptorBinding(AnimalStereotype.class); assert !getCurrentManager().isInterceptorBinding(ApplicationScoped.class); }
protected boolean isStereotypeWithInterceptor(Annotation stereotypeAnnotation, BeanManager beanManager) { for (Annotation annotation : stereotypeAnnotation.annotationType().getAnnotations()) { if (isStandardAnnotation(annotation)) { continue; } if (beanManager.isInterceptorBinding(annotation.annotationType()) || isStereotypeWithInterceptor(annotation, beanManager)) { return true; } } return false; }
if (beanManager.isInterceptorBinding(annotationType)) if (beanManager.isInterceptorBinding(subAnnotation.annotationType()))
private boolean containsInterceptorBinding(BeanManager beanManager, Annotation[] annotations) { for (Annotation annotation : annotations) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (beanManager.isInterceptorBinding(annotationType)) { return true; } if (beanManager.isStereotype(annotationType)) { boolean containsInterceptorBinding = containsInterceptorBinding( beanManager, annotationType.getDeclaredAnnotations()); if (containsInterceptorBinding) { return true; } } } return false; }
protected boolean isEjbOrAnnotatedTypeWithInterceptorAnnotation(BeanManager beanManager, Set<Annotation> annotations, String origin) { for (Annotation annotation : annotations) { if (annotation.annotationType().getName().startsWith(EJB_BASE_PACKAGE)) { return true; } if (isStandardAnnotation(annotation)) { continue; } if (beanManager.isInterceptorBinding(annotation.annotationType()) || (beanManager.isStereotype(annotation.annotationType()) && isStereotypeWithInterceptor(annotation, beanManager))) { LOG.warning("Skip mocking intercepted bean " + origin); return true; } } return false; }
.filter(a -> bm.isInterceptorBinding(a.annotationType())) .filter(a -> !a.annotationType().getName().startsWith("javax.cache.annotation") || acceptCache) .toArray(Annotation[]::new);
protected void promoteInterceptors(@Observes ProcessAnnotatedType pat) { if (priorityAnnotationInstance == null) //not CDI 1.1 or the extension is deactivated { return; } String beanClassName = pat.getAnnotatedType().getJavaClass().getName(); if (beanClassName.startsWith(DS_PACKAGE_NAME)) { if (pat.getAnnotatedType().isAnnotationPresent(Interceptor.class)) { //noinspection unchecked pat.setAnnotatedType(new GlobalInterceptorWrapper(pat.getAnnotatedType(), priorityAnnotationInstance)); } //currently not needed, because we don't use our interceptors internally -> check for the future else if (!beanClassName.contains(".test.")) { for (Annotation annotation : pat.getAnnotatedType().getAnnotations()) { if (beanManager.isInterceptorBinding(annotation.annotationType())) { //once we see this warning we need to introduce double-call prevention logic due to WELD-1780 LOG.warning(beanClassName + " is an bean from DeltaSpike which is intercepted."); } } } } } }