Refine search
/** * @return the index */ public Index getIndex () { if ( this.index == null ) { this.index = this.indexer.complete(); } return this.index; }
/** * 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; }
private void addToIndex(InputStream inputStream) { try { indexer.index(inputStream); } catch (IOException ex) { CommonLogger.LOG.couldNotOpenStreamForURL(inputStream, ex); } }
@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 ); }
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; } }
/** * 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; }
private void addToIndex(InputStream inputStream) { try { indexer.index(inputStream); } catch (IOException ex) { CommonLogger.LOG.couldNotOpenStreamForURL(inputStream, ex); } }
@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 ); }
@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); } } } } }
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()); }
private void addToIndex(InputStream inputStream) { try { indexer.index(inputStream); } catch (IOException ex) { CommonLogger.LOG.couldNotOpenStreamForURL(inputStream, ex); } }
private Index buildIndex() { return indexer.complete(); } }
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(); }
/** * Indexes a single file, except it was already analyzed. * * @param indexer * Indexer to use. * @param knownFiles * List of files already analyzed. New files will be added within this method. * @param classFile * Class file to analyze. * * @return TRUE if the file was indexed or FALSE if it was ignored. */ public static boolean indexClassFile(final Indexer indexer, final List<File> knownFiles, final File classFile) { if (knownFiles.contains(classFile)) { return false; } knownFiles.add(classFile); try (final InputStream in = classFile.toURI().toURL().openStream()) { indexer.index(in); } catch (final IOException ex) { throw new RuntimeException("Error indexing file: " + classFile, ex); } return true; }
private Index buildIndex() { return indexer.complete(); } }
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(); }