use of org.apache.openejb.Extensions in project tomee by apache.
the class ConfigurationFactory method configureApplication.
public AppInfo configureApplication(final AppModule appModule) throws OpenEJBException {
try {
final Collection<Class<?>> extensions = new HashSet<>();
final Collection<String> notLoaded = new HashSet<>();
final List<URL> libs = appModule.getAdditionalLibraries();
if (libs != null && libs.size() > 0) {
final Extensions.Finder finder = new Extensions.Finder("META-INF", false, libs.toArray(new URL[libs.size()]));
extensions.addAll(Extensions.findExtensions(finder));
notLoaded.addAll(finder.getResourcesNotLoaded());
}
for (final EjbModule ejb : appModule.getEjbModules()) {
try {
final URI uri = ejb.getModuleUri();
if (uri.isAbsolute()) {
final URL url = uri.toURL();
if (libs != null && !libs.contains(url)) {
final Extensions.Finder finder = new Extensions.Finder("META-INF", false, url);
extensions.addAll(Extensions.findExtensions(finder));
notLoaded.addAll(finder.getResourcesNotLoaded());
}
}
} catch (final IllegalArgumentException | MalformedURLException iae) {
logger.debug("can't look for server event listener for module " + ejb.getModuleUri(), iae);
} catch (final Exception e) {
logger.error("can't look for server event listener for module " + ejb.getJarLocation());
}
}
for (final WebModule web : appModule.getWebModules()) {
final List<URL> webLibs = web.getScannableUrls();
if (webLibs != null && webLibs.size() > 0) {
final Extensions.Finder finder = new Extensions.Finder("META-INF", false, webLibs.toArray(new URL[webLibs.size()]));
extensions.addAll(Extensions.findExtensions(finder));
notLoaded.addAll(finder.getResourcesNotLoaded());
}
}
// add it as early as possible, the ones needing the app classloader will be added later
Extensions.addExtensions(extensions);
final String location = appModule.getJarLocation();
logger.info("config.configApp", null != location ? location : appModule.getModuleId());
deployer.deploy(appModule);
final AppInfoBuilder appInfoBuilder = new AppInfoBuilder(this);
final AppInfo info = appInfoBuilder.build(appModule);
info.eventClassesNeedingAppClassloader.addAll(notLoaded);
return info;
} finally {
destroy(appModule.getEarLibFinder());
for (final EjbModule ejb : appModule.getEjbModules()) {
destroy(ejb.getFinder());
}
for (final WebModule web : appModule.getWebModules()) {
destroy(web.getFinder());
}
}
}
Aggregations