public static CompositeIndex createMerged(final CompositeIndex... indexes) { ArrayList<IndexView> list = new ArrayList<IndexView>(); for (CompositeIndex index : indexes) { list.addAll(index.indexes); } return create(list); }
public static CompositeIndex create(Collection<IndexView> indexes) { return new CompositeIndex(indexes); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }
protected List<Class<? extends ServerConfiguration>> findServerConfigurationImpls(Module module, List<Index> parentIndexes) throws ModuleLoadException, IOException, NoSuchFieldException, IllegalAccessException { List<Index> indexes = new ArrayList<>(); resolveBuildTimeIndex(module, indexes); //resolveRuntimeIndex(module, indexes); indexes.addAll(parentIndexes); CompositeIndex compositeIndex = CompositeIndex.create(indexes.toArray(new Index[indexes.size()])); List<Class<? extends ServerConfiguration>> impls = new ArrayList<>(); Set<ClassInfo> infos = compositeIndex.getAllKnownImplementors(DotName.createSimple(ServerConfiguration.class.getName())); for (ClassInfo info : infos) { if (info.name().toString().equals(AnnotationBasedServerConfiguration.class.getName())) { continue; } try { Class<? extends ServerConfiguration> cls = (Class<? extends ServerConfiguration>) module.getClassLoader().loadClass(info.name().toString()); if (!Modifier.isAbstract(cls.getModifiers())) { impls.add(cls); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } return impls; }
private Set<DotName> buildBeanDefiningAnnotationSet(Set<Class<? extends Annotation>> initialBeanDefiningAnnotations, CompositeIndex index) { ImmutableSet.Builder<DotName> beanDefiningAnnotations = ImmutableSet.builder(); for (Class<? extends Annotation> annotation : initialBeanDefiningAnnotations) { final DotName annotationDotName = DotName.createSimple(annotation.getName()); if (isMetaAnnotation(annotation)) { // find annotations annotated with this meta-annotation for (AnnotationInstance instance : index.getAnnotations(annotationDotName)) { if (instance.target() instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) instance.target(); if ((classInfo.flags() & ANNOTATION) != 0) { beanDefiningAnnotations.add(classInfo.name()); } } } } else { beanDefiningAnnotations.add(annotationDotName); } } return beanDefiningAnnotations.build(); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }
protected List<ServerConfiguration> findAnnotationServerConfigurations(Module apiModule, List<Index> parentIndexes) throws ModuleLoadException, IOException, NoSuchFieldException, IllegalAccessException { List<Index> indexes = new ArrayList<>(); resolveBuildTimeIndex(apiModule, indexes); //resolveRuntimeIndex(module, indexes); indexes.addAll(parentIndexes); CompositeIndex compositeIndex = CompositeIndex.create(indexes.toArray(new Index[indexes.size()])); List<ServerConfiguration> impls = new ArrayList<>(); DotName configAnno = DotName.createSimple(Configuration.class.getName()); Set<ClassInfo> infos = compositeIndex.getAllKnownImplementors(DotName.createSimple(Fraction.class.getName())); for (ClassInfo info : infos) { for (AnnotationInstance anno : info.classAnnotations()) { if (anno.name().equals(configAnno)) { try { ServerConfiguration config = fromAnnotation(apiModule, anno); impls.add(config); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } } return impls; }
private Set<DotName> buildBeanDefiningAnnotationSet(Set<Class<? extends Annotation>> initialBeanDefiningAnnotations, CompositeIndex index) { ImmutableSet.Builder<DotName> beanDefiningAnnotations = ImmutableSet.builder(); for (Class<? extends Annotation> annotation : initialBeanDefiningAnnotations) { final DotName annotationDotName = DotName.createSimple(annotation.getName()); if (isMetaAnnotation(annotation)) { // find annotations annotated with this meta-annotation for (AnnotationInstance instance : index.getAnnotations(annotationDotName)) { if (instance.target() instanceof ClassInfo) { ClassInfo classInfo = instance.target().asClass(); if ((classInfo.flags() & ANNOTATION) != 0) { beanDefiningAnnotations.add(classInfo.name()); } } } } else { beanDefiningAnnotations.add(annotationDotName); } } return beanDefiningAnnotations.build(); }
IndexView createDeploymentIndex(Archive<?> deployment) { List<IndexView> indexes = new ArrayList<IndexView>(); try { index(deployment, indexes); } catch (IOException e) { throw new RuntimeException(e); } return CompositeIndex.create(indexes); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }
private Set<DotName> buildBeanDefiningAnnotationSet(Set<Class<? extends Annotation>> initialBeanDefiningAnnotations, CompositeIndex index) { ImmutableSet.Builder<DotName> beanDefiningAnnotations = ImmutableSet.builder(); for (Class<? extends Annotation> annotation : initialBeanDefiningAnnotations) { final DotName annotationDotName = DotName.createSimple(annotation.getName()); if (isMetaAnnotation(annotation)) { // find annotations annotated with this meta-annotation for (AnnotationInstance instance : index.getAnnotations(annotationDotName)) { if (instance.target() instanceof ClassInfo) { ClassInfo classInfo = instance.target().asClass(); if ((classInfo.flags() & ANNOTATION) != 0) { beanDefiningAnnotations.add(classInfo.name()); } } } } else { beanDefiningAnnotations.add(annotationDotName); } } return beanDefiningAnnotations.build(); }
public static CompositeIndex create(final IndexView... indexes) { return new CompositeIndex(Arrays.asList(indexes)); }
IndexView createDeploymentIndex(Archive<?> deployment) { List<IndexView> indexes = new ArrayList<IndexView>(); try { index(deployment, indexes); } catch (IOException e) { throw new RuntimeException(e); } return CompositeIndex.create(indexes); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }
private Set<DotName> buildBeanDefiningAnnotationSet(Set<Class<? extends Annotation>> initialBeanDefiningAnnotations, CompositeIndex index) { ImmutableSet.Builder<DotName> beanDefiningAnnotations = ImmutableSet.builder(); for (Class<? extends Annotation> annotation : initialBeanDefiningAnnotations) { final DotName annotationDotName = DotName.createSimple(annotation.getName()); if (isMetaAnnotation(annotation)) { // find annotations annotated with this meta-annotation for (AnnotationInstance instance : index.getAnnotations(annotationDotName)) { if (instance.target() instanceof ClassInfo) { ClassInfo classInfo = instance.target().asClass(); if ((classInfo.flags() & ANNOTATION) != 0) { beanDefiningAnnotations.add(classInfo.name()); } } } } else { beanDefiningAnnotations.add(annotationDotName); } } return beanDefiningAnnotations.build(); }
IndexView createDeploymentIndex(Archive<?> deployment) { List<IndexView> indexes = new ArrayList<IndexView>(); try { index(deployment, indexes); } catch (IOException e) { throw new RuntimeException(e); } return CompositeIndex.create(indexes); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }
private Set<DotName> buildBeanDefiningAnnotationSet(Set<Class<? extends Annotation>> initialBeanDefiningAnnotations, CompositeIndex index) { ImmutableSet.Builder<DotName> beanDefiningAnnotations = ImmutableSet.builder(); for (Class<? extends Annotation> annotation : initialBeanDefiningAnnotations) { final DotName annotationDotName = DotName.createSimple(annotation.getName()); if (isMetaAnnotation(annotation)) { // find annotations annotated with this meta-annotation for (AnnotationInstance instance : index.getAnnotations(annotationDotName)) { if (instance.target() instanceof ClassInfo) { ClassInfo classInfo = instance.target().asClass(); if ((classInfo.flags() & ANNOTATION) != 0) { beanDefiningAnnotations.add(classInfo.name()); } } } } else { beanDefiningAnnotations.add(annotationDotName); } } return beanDefiningAnnotations.build(); }
@Override protected void beforeDiscovery(Collection<BeanArchiveBuilder> builders) { List<IndexView> indexes = new ArrayList<IndexView>(); for (BeanArchiveBuilder builder : builders) { IndexView index = (IndexView) builder.getAttribute(Jandex.INDEX_ATTRIBUTE_NAME); if (index != null) { indexes.add(index); } } cindex = CompositeIndex.create(indexes); beanDefiningAnnotations = buildBeanDefiningAnnotationSet(initialBeanDefiningAnnotations, cindex); classFileServices = new JandexClassFileServices(this); }
private boolean containsBeanDefiningAnnotation(ClassInfo cinfo, String className) { for (Entry<DotName, List<AnnotationInstance>> entry : cinfo.annotations().entrySet()) { if (beanDefiningAnnotations.contains(entry.getKey())) { return true; } if (isDeclaredOnBeanClass(entry, cinfo) && cindex.getClassByName(entry.getKey()) == null) { // Annotation not found in the composite index - falling back to reflection Class<?> clazz = Reflections.loadClass(resourceLoader, className); if (clazz != null) { for (Class<? extends Annotation> metaAnnotation : Reflections.META_ANNOTATIONS) { if (hasBeanDefiningMetaAnnotationSpecified(clazz.getAnnotations(), metaAnnotation)) { return true; } } } } } return false; }