/** * Merges bean interceptor bindings (including inherited ones) with method interceptor bindings. Method interceptor bindings * override bean interceptor bindings. The bean binding map is not modified - a copy is used. */ protected Map<Class<? extends Annotation>, Annotation> mergeMethodInterceptorBindings(Map<Class<? extends Annotation>, Annotation> beanBindings, Set<Annotation> methodBindingAnnotations) { Map<Class<? extends Annotation>, Annotation> mergedBeanBindings = new HashMap<Class<? extends Annotation>, Annotation>(beanBindings); // conflict detection Set<Class<? extends Annotation>> processedBindingTypes = new HashSet<Class<? extends Annotation>>(); for (Annotation methodBinding : methodBindingAnnotations) { Class<? extends Annotation> methodBindingType = methodBinding.annotationType(); if (processedBindingTypes.contains(methodBindingType)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(annotatedType)); } processedBindingTypes.add(methodBindingType); // override bean interceptor binding mergedBeanBindings.put(methodBindingType, methodBinding); } return mergedBeanBindings; }
private static void addInterceptorBindings(EnhancedAnnotatedType<?> clazz, Collection<Annotation> interceptorBindings, Set<Annotation> flattenInterceptorBindings, MetaAnnotationStore metaAnnotationStore) { for (Annotation annotation : interceptorBindings) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (!annotation.annotationType().isAnnotationPresent(Repeatable.class)) { for (Annotation binding : flattenInterceptorBindings) { if (binding.annotationType().equals(annotationType) && !metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(annotation, binding, false)) { if (clazz != null) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz)); } else { throw BeanManagerLogger.LOG.duplicateInterceptorBinding(annotation); } } } } flattenInterceptorBindings.add(annotation); } }
private static void addInterceptorBindings(EnhancedAnnotatedType<?> clazz, Collection<Annotation> interceptorBindings, Set<Annotation> flattenInterceptorBindings, MetaAnnotationStore metaAnnotationStore) { for (Annotation annotation : interceptorBindings) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (!annotation.annotationType().isAnnotationPresent(Repeatable.class)) { for (Annotation binding : flattenInterceptorBindings) { if (binding.annotationType().equals(annotationType) && !metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(annotation, binding, false)) { if (clazz != null) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz)); } else { throw BeanManagerLogger.LOG.duplicateInterceptorBinding(annotation); } } } } flattenInterceptorBindings.add(annotation); } }
private static void addInterceptorBindings(EnhancedAnnotatedType<?> clazz, Collection<Annotation> interceptorBindings, Set<Annotation> flattenInterceptorBindings, MetaAnnotationStore metaAnnotationStore) { for (Annotation annotation : interceptorBindings) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (!annotation.annotationType().isAnnotationPresent(Repeatable.class)) { for (Annotation binding : flattenInterceptorBindings) { if (binding.annotationType().equals(annotationType) && !metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(annotation, binding, false)) { if (clazz != null) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz)); } else { throw BeanManagerLogger.LOG.duplicateInterceptorBinding(annotation); } } } } flattenInterceptorBindings.add(annotation); } }
private static void addInterceptorBindings(EnhancedAnnotatedType<?> clazz, Collection<Annotation> interceptorBindings, Set<Annotation> flattenInterceptorBindings, MetaAnnotationStore metaAnnotationStore) { for (Annotation annotation : interceptorBindings) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (!annotation.annotationType().isAnnotationPresent(Repeatable.class)) { for (Annotation binding : flattenInterceptorBindings) { if (binding.annotationType().equals(annotationType) && !metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(annotation, binding, false)) { if (clazz != null) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz)); } else { throw BeanManagerLogger.LOG.duplicateInterceptorBinding(annotation); } } } } flattenInterceptorBindings.add(annotation); } }
private static void addInterceptorBindings(EnhancedAnnotatedType<?> clazz, Collection<Annotation> interceptorBindings, Set<Annotation> flattenInterceptorBindings, MetaAnnotationStore metaAnnotationStore) { for (Annotation annotation : interceptorBindings) { Class<? extends Annotation> annotationType = annotation.annotationType(); if (!annotation.annotationType().isAnnotationPresent(Repeatable.class)) { for (Annotation binding : flattenInterceptorBindings) { if (binding.annotationType().equals(annotationType) && !metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(annotation, binding, false)) { if (clazz != null) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz)); } else { throw BeanManagerLogger.LOG.duplicateInterceptorBinding(annotation); } } } } flattenInterceptorBindings.add(annotation); } }
if (mergedBeanBindings.containsKey(bindingAnnotation.annotationType())) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); && !beanManager.getServices().get(MetaAnnotationStore.class).getInterceptorBindingModel(bindingAnnotationType) .isEqual(previousValue, bindingAnnotation, true)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));
protected InterceptorImpl(BeanAttributes<T> attributes, EnhancedAnnotatedType<T> type, BeanManagerImpl beanManager) { super(attributes, type, new StringBeanIdentifier(forInterceptor(type)), beanManager); this.interceptorMetadata = initInterceptorMetadata(); this.serializable = type.isSerializable(); this.interceptorBindingTypes = Collections.unmodifiableSet(new HashSet<Annotation>(Interceptors.mergeBeanInterceptorBindings(beanManager, getEnhancedAnnotated(), getStereotypes()).values())); if (Beans.findInterceptorBindingConflicts(beanManager, interceptorBindingTypes)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(getType())); } }
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Map<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, AnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(beanManager, filterInterceptorBindings(beanManager, clazz.getAnnotations()), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(beanManager, filterInterceptorBindings(beanManager, clazz.getAnnotations()), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Multimap<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, EnhancedAnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> rawBindings = clazz.getMetaAnnotations(InterceptorBinding.class); Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); for (Annotation inheritedBinding : inheritedBindings) { if (!metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(binding, inheritedBinding, false)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Multimap<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, EnhancedAnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> rawBindings = clazz.getMetaAnnotations(InterceptorBinding.class); Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Multimap<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, EnhancedAnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> rawBindings = clazz.getMetaAnnotations(InterceptorBinding.class); Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); for (Annotation inheritedBinding : inheritedBindings) { if (!metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(binding, inheritedBinding, false)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));
throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); for (Annotation inheritedBinding : inheritedBindings) { if (!metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(binding, inheritedBinding, false)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Multimap<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, EnhancedAnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> rawBindings = clazz.getMetaAnnotations(InterceptorBinding.class); Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
/** * Merge class-level interceptor bindings with interceptor bindings inherited from interceptor bindings and stereotypes. */ public static Multimap<Class<? extends Annotation>, Annotation> mergeBeanInterceptorBindings(BeanManagerImpl beanManager, EnhancedAnnotatedType<?> clazz, Collection<Class<? extends Annotation>> stereotypes) { Set<Annotation> rawBindings = clazz.getMetaAnnotations(InterceptorBinding.class); Set<Annotation> classBindingAnnotations = flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), true, false); Set<Annotation> inheritedBindingAnnotations = new HashSet<Annotation>(); inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, rawBindings), false, true)); for (Class<? extends Annotation> annotation : stereotypes) { inheritedBindingAnnotations.addAll(flattenInterceptorBindings(clazz, beanManager, filterInterceptorBindings(beanManager, beanManager.getStereotypeDefinition(annotation)), true, true)); } try { return mergeBeanInterceptorBindings(beanManager, clazz, classBindingAnnotations, inheritedBindingAnnotations); } catch (DeploymentException e) { throw new DefinitionException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); } }
throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); for (Annotation inheritedBinding : inheritedBindings) { if (!metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(binding, inheritedBinding, false)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));
throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass())); for (Annotation inheritedBinding : inheritedBindings) { if (!metaAnnotationStore.getInterceptorBindingModel(annotationType).isEqual(binding, inheritedBinding, false)) { throw new DeploymentException(BeanLogger.LOG.conflictingInterceptorBindings(clazz.getJavaClass()));