org.jboss.jandex.CompositeIndex Java Examples

The following examples show how to use org.jboss.jandex.CompositeIndex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenerateYamlSupport.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
protected static IndexView getCompositeIndexer(ClassLoader classLoader) {
    try {
        Enumeration<URL> elements = classLoader.getResources("META-INF/jandex.idx");
        List<IndexView> allIndex = new ArrayList<>();
        Set<URL> locations = new HashSet<>();

        while (elements.hasMoreElements()) {
            URL url = elements.nextElement();
            if (locations.add(url)) {
                try (InputStream is = url.openStream()) {
                    allIndex.add(new IndexReader(is).read());
                }
            }
        }

        return CompositeIndex.create(allIndex);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: CombinedIndexBuildStep.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@BuildStep
CombinedIndexBuildItem build(ApplicationArchivesBuildItem archives,
        List<AdditionalIndexedClassesBuildItem> additionalIndexedClassesItems) {
    List<IndexView> archiveIndexes = new ArrayList<>();

    for (ApplicationArchive i : archives.getAllApplicationArchives()) {
        archiveIndexes.add(i.getIndex());
    }

    CompositeIndex archivesIndex = CompositeIndex.create(archiveIndexes);

    Indexer indexer = new Indexer();
    Set<DotName> additionalIndex = new HashSet<>();

    for (AdditionalIndexedClassesBuildItem additionalIndexedClasses : additionalIndexedClassesItems) {
        for (String classToIndex : additionalIndexedClasses.getClassesToIndex()) {
            IndexingUtil.indexClass(classToIndex, indexer, archivesIndex, additionalIndex,
                    Thread.currentThread().getContextClassLoader());
        }
    }

    return new CombinedIndexBuildItem(CompositeIndex.create(archivesIndex, indexer.complete()));
}
 
Example #3
Source File: BeanArchives.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param applicationIndexes
 * @return the final bean archive index
 */
public static IndexView buildBeanArchiveIndex(ClassLoader deploymentClassLoader, PersistentClassIndex persistentClassIndex,
        IndexView... applicationIndexes) {
    List<IndexView> indexes = new ArrayList<>();
    Collections.addAll(indexes, applicationIndexes);
    indexes.add(buildAdditionalIndex());
    return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, persistentClassIndex);
}
 
Example #4
Source File: HibernateOrmProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
public JpaModelIndexBuildItem jpaEntitiesIndexer(
        CombinedIndexBuildItem index,
        List<AdditionalJpaModelBuildItem> additionalJpaModelBuildItems) {
    // build a composite index with additional jpa model classes
    Indexer indexer = new Indexer();
    Set<DotName> additionalIndex = new HashSet<>();
    for (AdditionalJpaModelBuildItem jpaModel : additionalJpaModelBuildItems) {
        IndexingUtil.indexClass(jpaModel.getClassName(), indexer, index.getIndex(), additionalIndex,
                HibernateOrmProcessor.class.getClassLoader());
    }
    CompositeIndex compositeIndex = CompositeIndex.create(index.getIndex(), indexer.complete());
    return new JpaModelIndexBuildItem(compositeIndex);
}
 
Example #5
Source File: SmallRyeOpenApiProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
OpenApiFilteredIndexViewBuildItem smallryeOpenApiIndex(CombinedIndexBuildItem combinedIndexBuildItem,
        BeanArchiveIndexBuildItem beanArchiveIndexBuildItem) {
    CompositeIndex compositeIndex = CompositeIndex.create(combinedIndexBuildItem.getIndex(),
            beanArchiveIndexBuildItem.getIndex());
    return new OpenApiFilteredIndexViewBuildItem(
            new FilteredIndexView(
                    compositeIndex,
                    new OpenApiConfigImpl(ConfigProvider.getConfig())));
}
 
Example #6
Source File: DeploymentProducer.java    From thorntail with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #7
Source File: IndexInitializer.java    From smallrye-graphql with Apache License 2.0 4 votes vote down vote up
private IndexView merge(Collection<IndexView> indexes) {
    return CompositeIndex.create(indexes);
}
 
Example #8
Source File: KogitoAssetsProcessor.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
@BuildStep(loadsApplicationClasses = true)
public void generateModel(ArchiveRootBuildItem root,
                          BuildProducer<GeneratedBeanBuildItem> generatedBeans,
                          CombinedIndexBuildItem combinedIndexBuildItem,
                          LaunchModeBuildItem launchMode,
                          LiveReloadBuildItem liveReload,
                          BuildProducer<NativeImageResourceBuildItem> resource,
                          BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
                          CurateOutcomeBuildItem curateOutcomeBuildItem) throws IOException, BootstrapDependencyProcessingException {

    if (liveReload.isLiveReload()) {
        return;
    }

    AppPaths appPaths = new AppPaths( root.getPaths() );

    ApplicationGenerator appGen = createApplicationGenerator(appPaths, combinedIndexBuildItem);
    Collection<GeneratedFile> generatedFiles = appGen.generate();

    Collection<GeneratedFile> javaFiles = generatedFiles.stream().filter( f -> f.relativePath().endsWith( ".java" ) ).collect( Collectors.toCollection( ArrayList::new ));
    writeGeneratedFiles(appPaths, generatedFiles);

    if (!javaFiles.isEmpty()) {

        Indexer kogitoIndexer = new Indexer();
        Set<DotName> kogitoIndex = new HashSet<>();

        MemoryFileSystem trgMfs = new MemoryFileSystem();
        CompilationResult result = compile( appPaths, trgMfs, curateOutcomeBuildItem.getEffectiveModel(), javaFiles, launchMode.getLaunchMode() );
        register(appPaths, trgMfs, generatedBeans,
                (className, data) -> generateBeanBuildItem( combinedIndexBuildItem, kogitoIndexer, kogitoIndex, className, data ),
                launchMode.getLaunchMode(), result);


        Index index = kogitoIndexer.complete();

        generatePersistenceInfo(appPaths, generatedBeans, CompositeIndex.create(combinedIndexBuildItem.getIndex(), index),
                launchMode, resource, curateOutcomeBuildItem);


        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.event.AbstractDataEvent"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.AbstractProcessDataEvent"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.ProcessInstanceDataEvent"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.VariableInstanceDataEvent"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.impl.ProcessInstanceEventBody"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.impl.NodeInstanceEventBody"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.impl.ProcessErrorEventBody"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.impl.VariableInstanceEventBody"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.UserTaskInstanceDataEvent"));
        reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, "org.kie.kogito.services.event.impl.UserTaskInstanceEventBody"));

        Collection<ClassInfo> dataEvents = index
                .getAllKnownSubclasses(createDotName("org.kie.kogito.event.AbstractDataEvent"));

        dataEvents.forEach(c -> reflectiveClass.produce(
                new ReflectiveClassBuildItem(true, true, c.name().toString())));

        writeGeneratedFiles(appPaths, getJsonSchemaFiles(index, trgMfs));
    }
}
 
Example #9
Source File: JpaModelIndexBuildItem.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public JpaModelIndexBuildItem(CompositeIndex index) {
    this.index = index;
}
 
Example #10
Source File: JpaModelIndexBuildItem.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public CompositeIndex getIndex() {
    return index;
}