List<String> mappingFiles = metadata.getMappingFiles();
addScannedEntries( scanningContext, classes, packages, hbmFiles, mappingFiles );
}
private static void addScannedEntries(ScanningContext scanningContext, List<String> classes, List<String> packages, List<NamedInputStream> hbmFiles, List<String> mappingFiles) throws IOException {
Scanner scanner = scanningContext.scanner;
if (scanningContext.detectClasses) {
Set<Class<? extends Annotation>> annotationsToExclude = new HashSet<Class<? extends Annotation>>(3);
annotationsToExclude.add( Entity.class );
annotationsToExclude.add( MappedSuperclass.class );
annotationsToExclude.add( Embeddable.class );
Set<Class<?>> matchingClasses = scanner.getClassesInJar( scanningContext.url, annotationsToExclude );
for (Class<?> clazz : matchingClasses) {
classes.add( clazz.getName() );
}
Set<Package> matchingPackages = scanner.getPackagesInJar( scanningContext.url, new HashSet<Class<? extends Annotation>>(0) );
for (Package pkg : matchingPackages) {
packages.add( pkg.getName() );
}
}
Set<String> patterns = new HashSet<String>();
if (scanningContext.searchOrm) {
patterns.add( META_INF_ORM_XML );
}
if (scanningContext.detectHbmFiles) {
patterns.add( "**/*.hbm.xml" );
}
if ( mappingFiles != null) patterns.addAll( mappingFiles );
if (patterns.size() !=0) {
Set<NamedInputStream> files = scanner.getFilesInJar( scanningContext.url, patterns );
for (NamedInputStream file : files) {
hbmFiles.add( file );
if (mappingFiles != null) mappingFiles.remove( file.getName() );
}
}