final Set<RequireDescriptors> requireDescriptors = options.getAll(CLASSPATH_REQUIRE_DESCRIPTOR, RequireDescriptors.CLIENT);
final boolean filterDescriptors = options.get(CLASSPATH_FILTER_DESCRIPTORS, false);
final boolean filterSystemApps = options.get(CLASSPATH_FILTER_SYSTEMAPPS, true);
try {
UrlSet urlSet = new UrlSet(classLoader);
urlSet = URLs.cullSystemJars(urlSet);
// save the prefiltered list of jars before excluding system apps
// so that we can choose not to filter modules with descriptors on the full list
final UrlSet prefiltered = urlSet;
Filter includeFilter = Filters.patterns(include);
// we should exclude system apps before and apply user properties after
if (!".*".equals(include) || !"".equals(exclude)) { // if we are using default this will not do anything
// the next line should probably replaced by:
// final Filter filter = new ExcludeIncludeFilter(includeFilter, Filters.patterns(exclude));
final Filter filter;
if (EXCLUDE_INCLUDE_ORDER.startsWith("include")) { // this test should be simply enough
filter = new IncludeExcludeFilter(includeFilter, Filters.patterns(exclude));
} else {
filter = new ExcludeIncludeFilter(includeFilter, Filters.patterns(exclude));
}
// filter using user parameters
urlSet = urlSet.filter(filter);
} else {
includeFilter = null;
}
if (prefiltered.size() == urlSet.size()) {
urlSet = NewLoaderLogic.applyBuiltinExcludes(urlSet, includeFilter);
if (filterSystemApps) {
urlSet = urlSet.exclude(".*/openejb-[^/]+(.(jar|ear|war)(!/)?|/target/(test-)?classes/?)");
}
}
final List<URL> urls = new ArrayList<URL>();
final boolean isWindows = System.getProperty("os.name", "unknown").toLowerCase().startsWith("windows");
for (final URL url : urlSet.getUrls()) {
final String ef = isWindows ? url.toExternalForm().toLowerCase() : url.toExternalForm();
final URL u = new URL(ef);
if (!urls.contains(u)) {
urls.add(u);
}
}
final int size = urls.size();
if (size == 0 && include.length() > 0) {
logger.warning("No classpath URLs matched. Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
return;
} else if (size == 0 && !filterDescriptors && prefiltered.getUrls().size() == 0) {
return;
} else if (size < 20) {
logger.debug("Inspecting classpath for applications: " + urls.size() + " urls.");
} else {
// Has the user allowed some module types to be discoverable via scraping?
final boolean willScrape = requireDescriptors.size() < RequireDescriptors.values().length;
if (size < 50 && willScrape) {
logger.info("Inspecting classpath for applications: " +
urls.size() +
" urls. Consider adjusting your exclude/include. Current settings: " +
CLASSPATH_EXCLUDE +
"='" +
exclude +
"', " +
CLASSPATH_INCLUDE +
"='" +
include +
"'");
} else if (willScrape) {
logger.warning("Inspecting classpath for applications: " + urls.size() + " urls.");
logger.warning("ADJUST THE EXCLUDE/INCLUDE!!!. Current settings: " + CLASSPATH_EXCLUDE + "='" + exclude + "', " + CLASSPATH_INCLUDE + "='" + include + "'");
}
}
final long begin = System.currentTimeMillis();
processUrls("DeploymentsResolver1", urls, classLoader, requireDescriptors, base, jarList);
final long end = System.currentTimeMillis();
final long time = end - begin;
UrlSet unchecked = new UrlSet();
if (!filterDescriptors) {
unchecked = NewLoaderLogic.applyBuiltinExcludes(prefiltered.exclude(urlSet));
if (filterSystemApps) {
unchecked = unchecked.exclude(".*/openejb-[^/]+(.(jar|ear|war)(./)?|/target/classes/?)");
}
processUrls("DeploymentsResolver2", unchecked.getUrls(), classLoader, EnumSet.allOf(RequireDescriptors.class), base, jarList);
}
if (logger.isDebugEnabled()) {
final int urlCount = urlSet.getUrls().size() + unchecked.getUrls().size();
logger.debug("DeploymentsResolver: URLs after filtering: " + urlCount);
for (final URL url : urlSet.getUrls()) {
logger.debug("Annotations path: " + url);
}
for (final URL url : unchecked.getUrls()) {
logger.debug("Descriptors path: " + url);
}
}
if (urls.size() == 0) {