当前位置: 首页>>代码示例>>Java>>正文


Java Indexer类代码示例

本文整理汇总了Java中org.jboss.jandex.Indexer的典型用法代码示例。如果您正苦于以下问题:Java Indexer类的具体用法?Java Indexer怎么用?Java Indexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Indexer类属于org.jboss.jandex包,在下文中一共展示了Indexer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: index

import org.jboss.jandex.Indexer; //导入依赖的package包/类
@Produces
@DeploymentScoped
@Default
IndexView index() {
    Indexer indexer = new Indexer();
    Map<ArchivePath, Node> c = context.getCurrentArchive().getContent();
    try {
        for (Map.Entry<ArchivePath, Node> each : c.entrySet()) {
            if (each.getKey().get().endsWith(CLASS_SUFFIX)) {
                indexer.index(each.getValue().getAsset().openStream());
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return indexer.complete();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:19,代码来源:DeploymentProducer.java

示例2: createIndex

import org.jboss.jandex.Indexer; //导入依赖的package包/类
/**
 * Creates an annotation index for the given entity type
 */
public synchronized static Index createIndex(Class<?> type) {
    Index index = indices.get(type);
    if (index == null) {
        try {
            Indexer indexer = new Indexer();
            Class<?> currentType = type;
            while ( currentType != null ) {
                String className = currentType.getName().replace(".", "/") + ".class";
                InputStream stream = type.getClassLoader()
                        .getResourceAsStream(className);
                indexer.index(stream);
                currentType = currentType.getSuperclass();
            }
            index = indexer.complete();
            indices.put(type, index);
        } catch (IOException e) {
            throw new RuntimeException("Failed to initialize Indexer", e);
        }
    }
    return index;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:25,代码来源:IndexFactory.java

示例3: loadDependentIndexFromArchive

import org.jboss.jandex.Indexer; //导入依赖的package包/类
protected IndexView loadDependentIndexFromArchive(File archive) throws IOException {
    try (JarFile jar = new JarFile(archive)) {

        ZipEntry entry = jar.getEntry("META-INF/" + Jandexer.INDEX_NAME);
        if (entry != null) {
            return loadIndex(jar.getInputStream(entry));

        }
        Indexer indexer = new Indexer();

        Enumeration<JarEntry> entries = jar.entries();

        while (entries.hasMoreElements()) {
            JarEntry each = entries.nextElement();
            if (each.getName().endsWith(".class") && !each.getName().equals("module-info.class")) {
                try (InputStream in = jar.getInputStream(each)) {
                    indexer.index(in);
                }
            }

        }

        return indexer.complete();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:26,代码来源:ConfigurableDocumentationGenerator.java

示例4: calculateModuleIndex

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private Index calculateModuleIndex(final Module module) throws ModuleLoadException, IOException {
    final Indexer indexer = new Indexer();
    final PathFilter filter = PathFilters.getDefaultImportFilter();
    final Iterator<Resource> iterator = module.iterateResources(filter);
    while (iterator.hasNext()) {
        Resource resource = iterator.next();
        if(resource.getName().endsWith(".class")) {
            try (InputStream in = resource.openStream()) {
                indexer.index(in);
            } catch (Exception e) {
                ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(resource.getName(), resource.getURL().toExternalForm(), e);
            }
        }
    }
    return indexer.complete();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:CompositeIndexProcessor.java

示例5: transform

import org.jboss.jandex.Indexer; //导入依赖的package包/类
@Override
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
    Indexer indexer = new Indexer();

    for (String moduleName : modules) {
        ResourcePoolModule module = in.moduleView()
            .findModule( moduleName )
            .orElseThrow( () -> new RuntimeException("Module " + moduleName + "wasn't found" ) );

        module.entries()
            .filter( this::shouldAddToIndex )
            .forEach( e -> addToIndex( indexer, e ) );
    }

    ByteArrayOutputStream index = writeToOutputStream( indexer );
    out.add( ResourcePoolEntry.create( "/" + targetModule + "/META-INF/jandex.idx", index.toByteArray() ) );

    in.transformAndCopy(
        e -> e,
        out
    );

    return out.build();
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:25,代码来源:AddIndexPlugin.java

示例6: indexForClass

import org.jboss.jandex.Indexer; //导入依赖的package包/类
/**
 * Creates a jandex index for the specified classes
 *
 * @param classLoaderService class loader service
 * @param classes the classes to index
 *
 * @return an annotation repository w/ all the annotation discovered in the specified classes
 */
public static Index indexForClass(ClassLoaderService classLoaderService, Class<?>... classes) {
	Indexer indexer = new Indexer();
	for ( Class<?> clazz : classes ) {
		InputStream stream = classLoaderService.locateResourceStream(
				clazz.getName().replace( '.', '/' ) + ".class"
		);
		try {
			indexer.index( stream );
		}
		catch ( IOException e ) {
			StringBuilder builder = new StringBuilder();
			builder.append( "[" );
			int count = 0;
			for ( Class<?> c : classes ) {
				builder.append( c.getName() );
				if ( count < classes.length - 1 ) {
					builder.append( "," );
				}
				count++;
			}
			builder.append( "]" );
			throw new HibernateException( "Unable to create annotation index for " + builder.toString() );
		}
	}
	return indexer.complete();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:JandexHelper.java

示例7: prepare

import org.jboss.jandex.Indexer; //导入依赖的package包/类
@Override
@SuppressWarnings( { "unchecked" })
public void prepare(MetadataSources sources) {
	// create a jandex index from the annotated classes
	Indexer indexer = new Indexer();
	for ( Class<?> clazz : sources.getAnnotatedClasses() ) {
		indexClass( indexer, clazz.getName().replace( '.', '/' ) + ".class" );
	}

	// add package-info from the configured packages
	for ( String packageName : sources.getAnnotatedPackages() ) {
		indexClass( indexer, packageName.replace( '.', '/' ) + "/package-info.class" );
	}

	Index index = indexer.complete();

	List<JaxbRoot<JaxbEntityMappings>> mappings = new ArrayList<JaxbRoot<JaxbEntityMappings>>();
	for ( JaxbRoot<?> root : sources.getJaxbRootList() ) {
		if ( root.getRoot() instanceof JaxbEntityMappings ) {
			mappings.add( (JaxbRoot<JaxbEntityMappings>) root );
		}
	}
	if ( !mappings.isEmpty() ) {
		index = parseAndUpdateIndex( mappings, index );
	}

	if ( index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ) != null ) {
		// todo : this needs to move to AnnotationBindingContext
		// what happens right now is that specifying this in an orm.xml causes it to effect all orm.xmls
		metadata.setGloballyQuotedIdentifiers( true );
	}
	bindingContext = new AnnotationBindingContextImpl( metadata, index );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:AnnotationMetadataSourceProcessorImpl.java

示例8: indexClass

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private void indexClass(Indexer indexer, String className) {
	InputStream stream = metadata.getServiceRegistry().getService( ClassLoaderService.class ).locateResourceStream(
			className
	);
	try {
		indexer.index( stream );
	}
	catch ( IOException e ) {
		throw new HibernateException( "Unable to open input stream for class " + className, e );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AnnotationMetadataSourceProcessorImpl.java

示例9: createIndex

import org.jboss.jandex.Indexer; //导入依赖的package包/类
Index createIndex(Archive<?> archive) throws IOException {
    Indexer indexer = new Indexer();

    Map<ArchivePath, Node> c = archive.getContent();
    for (Map.Entry<ArchivePath, Node> each : c.entrySet()) {
        if (each.getKey().get().endsWith(".class")) {
            indexer.index(each.getValue().getAsset().openStream());
        }
    }


    return indexer.complete();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:14,代码来源:AdvertisingMetadataProcessorTest.java

示例10: addToIndex

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private void addToIndex(Indexer indexer, ResourcePoolEntry entry) {
    try {
        indexer.index( entry.content() );
    }
    catch(Exception ex) {
        throw new RuntimeException( ex );
    }
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:9,代码来源:AddIndexPlugin.java

示例11: indexAllClasses

import org.jboss.jandex.Indexer; //导入依赖的package包/类
/**
 * Index all class files in the given list.
 * 
 * @param indexer
 *            Indexer to use.
 * @param classFiles
 *            List of ".class" files.
 */
public static final void indexAllClasses(final Indexer indexer, final List<File> classFiles) {
    classFiles.forEach(file -> {
        try {
            final InputStream in = new FileInputStream(file);
            try {
                indexer.index(in);
            } finally {
                in.close();
            }
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
    });
}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:23,代码来源:Units4JUtils.java

示例12: testAssertThat

import org.jboss.jandex.Indexer; //导入依赖的package包/类
@Test
public void testAssertThat() {

    // TEST
    final Indexer indexer = new Indexer();
    final Index actual = indexer.complete();
    final JandexAssert result = JandexAssert.assertThat(actual);

    // VERIFY
    assertThat(result).isNotNull();

}
 
开发者ID:fuinorg,项目名称:units4j,代码行数:13,代码来源:JandexAssertTest.java

示例13: indexClassURL

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private static void indexClassURL(URL classURL, Indexer indexer, ServletContext context){

        try {

            if(!isClassFile(classURL))
                return;

            indexer.index(classURL.openStream());

        }catch (Throwable ex){

            log.error(String.format("Error indexing class: %s",classURL.toString()),ex);
            return;

        }

    }
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:18,代码来源:BootstrapUtils.java

示例14: getIndexForClass

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private Index getIndexForClass(URLClassLoader classLoader, String className) throws IOException {
	Indexer indexer = new Indexer();
	indexer.index(classLoader.getResourceAsStream(className));
	return indexer.complete();
}
 
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:6,代码来源:PathAnalyzer.java

示例15: indexDirectory

import org.jboss.jandex.Indexer; //导入依赖的package包/类
private static void indexDirectory(File directory, Indexer indexer, ServletContext context){

        File[] files = directory.listFiles();
        if(files==null)
            return;


        for(File file : files){

            if(file.isDirectory()) {
                indexDirectory(file, indexer,context);
                continue;
            }

            try {

                indexClassURL(file.toURI().toURL(),indexer,context);

            }catch (IOException ex){



            }

        }

    }
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:28,代码来源:BootstrapUtils.java


注:本文中的org.jboss.jandex.Indexer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。