public String getUnqualifiedJarName(URL jarToScan) { JarVisitor jarVisitor = getVisitor( jarToScan ); return jarVisitor.getUnqualifiedJarName(); }
/** * This implementation does not honor the list of annotations and return everything. * Must strictly be used by HEM */ public Set<Package> getPackagesInJar(URL jarToScan, Set<Class<? extends Annotation>> annotationsToLookFor) { if ( annotationsToLookFor.size() > 0 ) { throw new AssertionFailure( "Improper use of NativeScanner: must not filter packages" ); } JarVisitor jarVisitor = getVisitor( jarToScan ); final Set<Entry> packageEntries; try { packageEntries = ( Set<Entry> ) jarVisitor.getMatchingEntries()[PACKAGE_FILTER_INDEX]; } catch ( IOException e ) { throw new RuntimeException( "Error while reading " + jarToScan.toString(), e ); } Set<Package> packages = new HashSet<Package>( packageEntries.size() ); for ( Entry entry : packageEntries ) { try { packages.add( ReflectHelper.classForName( entry.getName() + ".package-info" ).getPackage() ); } catch ( ClassNotFoundException e ) { //should never happen, if it happens, simply ignore the flawed package } } return packages; }
public Set<Class<?>> getClassesInJar(URL jarToScan, Set<Class<? extends Annotation>> annotationsToLookFor) { if ( isValidForClasses( annotationsToLookFor ) ) { throw new AssertionFailure( "Improper use of NativeScanner: " + "must not filter classes by other annotations than Entity, MappedSuperclass, embeddable" ); } JarVisitor jarVisitor = getVisitor( jarToScan ); final Set<Entry> classesEntry; try { classesEntry = ( Set<Entry> ) jarVisitor.getMatchingEntries()[CLASS_FILTER_INDEX]; } catch ( IOException e ) { throw new RuntimeException( "Error while reading " + jarToScan.toString(), e ); } Set<Class<?>> classes = new HashSet<Class<?>>( classesEntry.size() ); for ( Entry entry : classesEntry ) { try { classes.add( ReflectHelper.classForName( entry.getName() ) ); } catch ( ClassNotFoundException e ) { //should never happen, if it happens, simply ignore the flawed package } } return classes; }
sb.append( " " ).append( pattern ).append( "\n" ); JarVisitor jarVisitor = getVisitor( jarToScan );