本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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 );
}
示例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 );
}
}
示例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();
}
示例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 );
}
}
示例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);
}
});
}
示例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();
}
示例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;
}
}
示例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();
}
示例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){
}
}
}