本文整理了Java中org.jboss.jandex.Indexer.<init>()
方法的一些代码示例,展示了Indexer.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Indexer.<init>()
方法的具体详情如下:
包路径:org.jboss.jandex.Indexer
类名称:Indexer
方法名:<init>
暂无
代码示例来源:origin: wildfly/wildfly
} else {
Indexer indexer = new Indexer();
consumer = (name, classFile) -> {
try (InputStream in = classFile.openStream()) {
代码示例来源:origin: spring-projects/sts4
private static IndexView createJarIndex(File indexFile, File jarFile) {
try {
return JarIndexer.createJarIndex(jarFile, new Indexer(), indexFile, false, false,
false, System.out, System.err).getIndex();
} catch (Exception e) {
log.error("Failed to index '" + jarFile + "'", e);
return null;
}
}
代码示例来源:origin: org.wildfly.swarm/config-api-runtime
/**
* 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;
}
代码示例来源:origin: io.thorntail/config-api-runtime
/**
* 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;
}
代码示例来源:origin: wildfly/jandex
@Override
public void execute() throws BuildException {
if (!run) {
return;
}
if (modify && newJar) {
throw new BuildException("Specifying both modify and newJar does not make sense.");
}
Indexer indexer = new Indexer();
for(FileSet fileset : filesets) {
String[] files = fileset.getDirectoryScanner(getProject()).getIncludedFiles();
for(String file : files) {
if (file.endsWith(".jar")) {
try {
JarIndexer.createJarIndex(new File(fileset.getDir().getAbsolutePath() + "/" +file), indexer, modify, newJar,verbose);
} catch (IOException e) {
throw new BuildException(e);
}
}
}
}
}
代码示例来源:origin: spring-projects/sts4
private static IndexView indexFolder(File folder) {
Indexer indexer = new Indexer();
for (Iterator<File> itr = com.google.common.io.Files.fileTreeTraverser().breadthFirstTraversal(folder)
.iterator(); itr.hasNext();) {
File file = itr.next();
if (file.isFile() && file.getName().endsWith(".class")) {
try {
final InputStream stream = new FileInputStream(file);
try {
indexer.index(stream);
} finally {
try {
stream.close();
} catch (Exception ignore) {
}
}
} catch (Exception e) {
log.error("Failed to index file " + file, e);
}
}
}
return indexer.complete();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
Indexer indexer = new Indexer();
for ( Class<?> clazz : classes ) {
InputStream stream = classLoaderService.locateResourceStream(
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
Indexer indexer = new Indexer();
for ( Class<?> clazz : classes ) {
InputStream stream = classLoaderService.locateResourceStream(
代码示例来源:origin: org.wildfly.swarm/container-runtime
private void resolveRuntimeIndex(Module module, List<Index> indexes) throws ModuleLoadException {
Indexer indexer = new Indexer();
Iterator<Resource> resources = module.iterateResources(PathFilters.acceptAll());
while (resources.hasNext()) {
Resource each = resources.next();
if (each.getName().endsWith(".class")) {
try {
ClassInfo clsInfo = indexer.index(each.openStream());
} catch (IOException e) {
//System.err.println("error: " + each.getName() + ": " + e.getMessage());
}
}
}
indexes.add(indexer.complete());
}
代码示例来源:origin: wildfly/jandex
private Index getIndex(long start) throws IOException {
Indexer indexer = new Indexer();
Result result = (source.isDirectory()) ? indexDirectory(source, indexer) : JarIndexer.createJarIndex(source, indexer, outputFile, modify, jarFile, verbose);
double time = (System.currentTimeMillis() - start) / 1000.00;
System.out.printf("Wrote %s in %.4f seconds (%d classes, %d annotations, %d instances, %d bytes)\n", result.getName(), time, result.getClasses(), result.getAnnotations(), result.getInstances(), result.getBytes());
return result.getIndex();
}
代码示例来源:origin: org.wildfly.core/wildfly-server
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();
}
代码示例来源:origin: wildfly/wildfly-core
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();
}
代码示例来源:origin: thorntail/thorntail
String[] locations = classpath.split(System.getProperty("path.separator"));
Indexer indexer = new Indexer();
代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm
protected List<Class<? extends ServerConfiguration>> findServerConfigurationImpls(Module module) throws ModuleLoadException, IOException, NoSuchFieldException, IllegalAccessException {
Indexer indexer = new Indexer();
Iterator<Resource> resources = module.iterateResources(PathFilters.acceptAll());
while (resources.hasNext()) {
Resource each = resources.next();
if (each.getName().endsWith(".class")) {
try {
ClassInfo clsInfo = indexer.index(each.openStream());
} catch (IOException e) {
//System.err.println("error: " + each.getName() + ": " + e.getMessage());
}
}
}
Index index = indexer.complete();
Set<ClassInfo> infos = index.getAllKnownImplementors(DotName.createSimple(ServerConfiguration.class.getName()));
List<Class<? extends ServerConfiguration>> impls = new ArrayList<>();
for (ClassInfo info : infos) {
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;
//List<AnnotationInstance> found = index.getAnnotations(DotName.createSimple(Configuration.class.getName()));
//return found;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
@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 );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
@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 );
}
代码示例来源:origin: thorntail/thorntail
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException {
Indexer indexer = new Indexer();
Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll());
while (iter.hasNext()) {
Resource each = iter.next();
if (each.getName().endsWith(".class")) {
if (!each.getName().equals("module-info.class")) {
try (InputStream is = each.openStream()) {
indexer.index(is);
} catch (IOException e) {
// ignore
}
}
}
}
Index index = indexer.complete();
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
for (ClassInfo each : impls) {
String name = each.name().toString();
Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name);
try {
ConfigurationFilter filter = cls.newInstance();
this.configView.withFilter(filter);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: io.thorntail/container
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException {
Indexer indexer = new Indexer();
Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll());
while (iter.hasNext()) {
Resource each = iter.next();
if (each.getName().endsWith(".class")) {
if (!each.getName().equals("module-info.class")) {
try (InputStream is = each.openStream()) {
indexer.index(is);
} catch (IOException e) {
// ignore
}
}
}
}
Index index = indexer.complete();
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
for (ClassInfo each : impls) {
String name = each.name().toString();
Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name);
try {
ConfigurationFilter filter = cls.newInstance();
this.configView.withFilter(filter);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: org.wildfly.swarm/container
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException {
Indexer indexer = new Indexer();
Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll());
while (iter.hasNext()) {
Resource each = iter.next();
if (each.getName().endsWith(".class")) {
if (!each.getName().equals("module-info.class")) {
try (InputStream is = each.openStream()) {
indexer.index(is);
} catch (IOException e) {
// ignore
}
}
}
}
Index index = indexer.complete();
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
for (ClassInfo each : impls) {
String name = each.name().toString();
Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name);
try {
ConfigurationFilter filter = cls.newInstance();
this.configView.withFilter(filter);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: org.jboss.as/jboss-as-domain
final Indexer indexer = new Indexer();
try {
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
内容来源于网络,如有侵权,请联系作者删除!