+
+ /** Add the remaining class-path-elements */
+ completeClassPath(classLoader);
+
+ /** Apply mappings from hibernate-configuration, if present */
+ if (config != null)
+ {
+ for (MappingReference mapping : config.getMappingReferences())
+ mapping.apply(sources);
+ }
+
+ Set<String> classes;
+ if (unit == null)
+ {
+ /** No persistent unit: default behaviour */
+ if (scanClasses == null)
+ scanClasses = true;
+ Set<URL> urls = new HashSet<URL>();
+ if (scanClasses)
+ addRoot(urls, outputDirectory);
+ if (scanTestClasses)
+ addRoot(urls, testOutputDirectory);
+ addDependencies(urls);
+ classes = scanUrls(urls);
+ }
+ else
+ {
+ /** Follow configuration in persisten unit */
+ if (scanClasses == null)
+ scanClasses = !unit.isExcludeUnlistedClasses();
+ Set<URL> urls = new HashSet<URL>();
+ if (scanClasses)
+ {
+ /**
+ * Scan the root of the persiten unit and configured jars for
+ * annotated classes
+ */
+ urls.add(unit.getPersistenceUnitRootUrl());
+ for (URL url : unit.getJarFileUrls())
+ urls.add(url);
+ }
+ if (scanTestClasses)
+ addRoot(urls, testOutputDirectory);
+ classes = scanUrls(urls);
+ for (String className : unit.getManagedClassNames())
+ classes.add(className);
+ }
+
+ /** Add the configured/collected annotated classes */
+ for (String className : classes)
+ addAnnotated(className, sources, classLoaderService, tracker);
+
+ /** Add explicitly configured classes */