for (Entry<ResourceRoot, Collection<ComponentDescription>> entry : components.componentDescriptions.entrySet()) { BeanDeploymentArchiveImpl bda = bdaMap.get(entry.getKey()); String id = null;
private Set<String> getImplicitBeanClasses(Index index, ResourceRoot resourceRoot) { Set<String> implicitBeanClasses = new HashSet<String>(); for (AnnotationType beanDefiningAnnotation : beanDefiningAnnotations) { List<AnnotationInstance> annotationInstances = index.getAnnotations(beanDefiningAnnotation.getName()); for (ClassInfo classInfo : Indices.getAnnotatedClasses(annotationInstances)) { implicitBeanClasses.add(Indices.CLASS_INFO_TO_FQCN.apply(classInfo)); } } // Make all explicit components into implicit beans so they will support injection for(ComponentDescription description : components.componentDescriptions.get(resourceRoot)) { if(!components.implicitComponentDescriptions.contains(description)) { implicitBeanClasses.add(description.getComponentClassName()); } } return implicitBeanClasses; }
public Components(DeploymentUnit deploymentUnit, Map<ResourceRoot, Index> indexes) { componentDescriptionProcessors = ServiceLoader.load(ComponentDescriptionProcessor.class, WildFlySecurityManager.getClassLoaderPrivileged(BeanArchiveProcessor.class)); for (ComponentDescription component : deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION).getComponentDescriptions()) { ResourceRoot resourceRoot = null; DotName componentClassName = DotName.createSimple(component.getComponentClassName()); for (Entry<ResourceRoot, Index> entry : indexes.entrySet()) { final Index index = entry.getValue(); if (index != null) { if (index.getClassByName(componentClassName) != null) { resourceRoot = entry.getKey(); break; } } } if (resourceRoot == null) { implicitComponentDescriptions.add(component); } if (resourceRoot == null || isClassesRoot(resourceRoot)) { // special handling resourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); } componentDescriptions.put(resourceRoot, component); // Process component descriptions for (ComponentDescriptionProcessor processor : componentDescriptionProcessors) { processor.processComponentDescription(resourceRoot, component); } } }
declaredFieldsTemp.add(annotatedField); for (Annotation annotation : annotatedField.getAnnotations()) { declaredAnnotatedFields.put(annotation.annotationType(), annotatedField); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { fieldsTemp = Sets.union(fieldsTemp, Reflections.<Set<EnhancedAnnotatedField<?, ? super T>>>cast(superclass.getFields())); annotatedFields.put(annotation.annotationType(), weldField); if (annotatedField.getDeclaringType().getJavaClass().equals(javaClass)) { declaredAnnotatedFields.put(annotation.annotationType(), weldField); this.declaredAnnotatedFields = Multimaps.unmodifiableMultimap(declaredAnnotatedFields); EnhancedAnnotatedMethod<?, ? super T> weldMethod = EnhancedAnnotatedMethodImpl.of(method, this, classTransformer); declaredMethodsTemp.add(weldMethod); for (Annotation annotation : weldMethod.getAnnotations()) { declaredAnnotatedMethods.put(annotation.annotationType(), weldMethod); if (weldMethod.getEnhancedParameters(annotationType).size() > 0) { declaredMethodsByAnnotatedParameters.put(annotationType, weldMethod); declaredAnnotatedMethods.put(annotation.annotationType(), enhancedMethod); declaredMethodsByAnnotatedParameters.put(annotationType, enhancedMethod); this.declaredAnnotatedMethods = Multimaps.unmodifiableMultimap(declaredAnnotatedMethods); methodsTemp.removeAll(getOverriddenMethods(this, methodsTemp, true));
/** * * @param annotatedType * @param methods * @param skipOverridingBridgeMethods If set to <code>true</code> the returning set will not contain methods overriden by a bridge method * @return the set of overriden methods */ protected Set<EnhancedAnnotatedMethod<?, ? super T>> getOverriddenMethods(EnhancedAnnotatedType<T> annotatedType, Set<EnhancedAnnotatedMethod<?, ? super T>> methods, boolean skipOverridingBridgeMethods) { Set<EnhancedAnnotatedMethod<?, ? super T>> overriddenMethods = new HashSet<EnhancedAnnotatedMethod<?, ? super T>>(); Multimap<MethodSignature, Package> seenMethods = SetMultimap.newSetMultimap(); for (Class<? super T> clazz = annotatedType.getJavaClass(); clazz != null && clazz != Object.class; clazz = clazz.getSuperclass()) { for (EnhancedAnnotatedMethod<?, ? super T> method : methods) { if (method.getJavaMember().getDeclaringClass().equals(clazz)) { if (skipOverridingBridgeMethods && method.getJavaMember().isBridge()) { continue; } if (isOverridden(method, seenMethods)) { overriddenMethods.add(method); } seenMethods.put(method.getSignature(), method.getPackage()); } } } return immutableSetView(overriddenMethods); }
private static boolean isOverridden(EnhancedAnnotatedMethod<?, ?> method, Multimap<MethodSignature, Package> seenMethods) { if (method.isPrivate()) { return false; } else if (method.isPackagePrivate() && seenMethods.containsKey(method.getSignature())) { return seenMethods.get(method.getSignature()).contains(method.getPackage()); } else { return seenMethods.containsKey(method.getSignature()); } }
/** * 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 Multimap<Class<? extends Annotation>, Annotation> mergeMemberInterceptorBindings(Multimap<Class<? extends Annotation>, Annotation> beanBindings, Set<Annotation> methodBindingAnnotations) { Multimap<Class<? extends Annotation>, Annotation> mergedBeanBindings = SetMultimap.newSetMultimap(beanBindings); Multimap<Class<? extends Annotation>, Annotation> methodBindings = SetMultimap.newSetMultimap(); for (Annotation methodBinding : methodBindingAnnotations) { methodBindings.put(methodBinding.annotationType(), methodBinding); } for (Class<? extends Annotation> key : methodBindings.keySet()) { mergedBeanBindings.replaceValues(key, methodBindings.get(key)); } return mergedBeanBindings; }
protected Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> buildAnnotatedParameterMethodMultimap(Set<EnhancedAnnotatedMethod<?, ? super T>> effectiveMethods) { Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> result = SetMultimap.newSetMultimap(); for (EnhancedAnnotatedMethod<?, ? super T> method : effectiveMethods) { for (Class<? extends Annotation> annotation : MAPPED_METHOD_PARAMETER_ANNOTATIONS) { if (!method.getEnhancedParameters(annotation).isEmpty()) { result.put(annotation, method); } } } return Multimaps.unmodifiableMultimap(result); }
protected Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> buildAnnotatedMethodMultimap(Set<EnhancedAnnotatedMethod<?, ? super T>> effectiveMethods) { Multimap<Class<? extends Annotation>, EnhancedAnnotatedMethod<?, ? super T>> result = SetMultimap.newSetMultimap(); for (EnhancedAnnotatedMethod<?, ? super T> method : effectiveMethods) { for (Class<? extends Annotation> annotation : MAPPED_METHOD_ANNOTATIONS) { if (method.isAnnotationPresent(annotation)) { result.put(annotation, method); } } } return Multimaps.unmodifiableMultimap(result); }
/** * Returns unmodifiable collections. Moreover, it does not trigger initialization of a new value collection (i.e. when no collection of values for a * given key exists). */ @Override public Collection<V> get(K key) { if (delegate.containsKey(key)) { return unmodifiableValueCollection(delegate.get(key)); } return Collections.emptyList(); }
/** * Gets the abstracted field annotated with a specific annotation type * <p/> * If the fields map is null, initialize it first * * @param annotationType The annotation type to match * @return A set of matching abstracted fields, null if none are found. */ @Override public Collection<EnhancedAnnotatedField<?, ?>> getEnhancedFields(Class<? extends Annotation> annotationType) { if (annotatedFields == null) { // Build collection from class hierarchy ArrayList<EnhancedAnnotatedField<?, ?>> aggregatedFields = new ArrayList<EnhancedAnnotatedField<?, ?>>(this.declaredAnnotatedFields.get(annotationType)); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { aggregatedFields.addAll(superclass.getEnhancedFields(annotationType)); } return Collections.unmodifiableCollection(aggregatedFields); } else { // Return results collected directly from AnnotatedType return annotatedFields.get(annotationType); } }
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 = Interceptors.mergeBeanInterceptorBindings(beanManager, getEnhancedAnnotated(), getStereotypes()).uniqueValues(); }
@Override public boolean isEmpty() { return delegate.isEmpty(); }
@Override public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType) { return declaredMetaAnnotationMap.containsKey(metaAnnotationType) ? ImmutableSet.copyOf(declaredMetaAnnotationMap.get(metaAnnotationType)) : Collections.emptySet(); }
@Override public Set<V> uniqueValues() { return delegate.uniqueValues(); }
@Override public List<V> values() { return delegate.values(); }
@Override public Set<K> keySet() { return delegate.keySet(); }
@Override public int size() { return delegate.size(); }
declaredFieldsTemp.add(annotatedField); for (Annotation annotation : annotatedField.getAnnotations()) { declaredAnnotatedFields.put(annotation.annotationType(), annotatedField); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { fieldsTemp = Sets.union(fieldsTemp, Reflections.<Set<EnhancedAnnotatedField<?, ? super T>>>cast(superclass.getFields())); annotatedFields.put(annotation.annotationType(), weldField); if (annotatedField.getDeclaringType().getJavaClass().equals(javaClass)) { declaredAnnotatedFields.put(annotation.annotationType(), weldField); this.declaredAnnotatedFields = Multimaps.unmodifiableMultimap(declaredAnnotatedFields); EnhancedAnnotatedMethod<?, ? super T> weldMethod = EnhancedAnnotatedMethodImpl.of(method, this, classTransformer); declaredMethodsTemp.add(weldMethod); for (Annotation annotation : weldMethod.getAnnotations()) { declaredAnnotatedMethods.put(annotation.annotationType(), weldMethod); if (weldMethod.getEnhancedParameters(annotationType).size() > 0) { declaredMethodsByAnnotatedParameters.put(annotationType, weldMethod); declaredAnnotatedMethods.put(annotation.annotationType(), enhancedMethod); declaredMethodsByAnnotatedParameters.put(annotationType, enhancedMethod); this.declaredAnnotatedMethods = Multimaps.unmodifiableMultimap(declaredAnnotatedMethods); methodsTemp.removeAll(getOverriddenMethods(this, methodsTemp, true));