use of org.apache.openejb.assembler.classic.AppInfo 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<Class<?>>();
final Collection<String> notLoaded = new HashSet<String>();
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());
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class AutoDeployer method fileAdded.
private boolean fileAdded(final File file) {
final String appPath = file.getAbsolutePath();
logger.info("Starting Auto-Deployment of: " + appPath);
try {
final AppInfo appInfo = factory.configureApplication(file);
appInfo.paths.add(appPath);
appInfo.paths.add(appInfo.path);
if (logger.isDebugEnabled()) {
for (final String path : appInfo.paths) {
logger.debug("Auto-Deployment path: " + path);
}
}
final Assembler assembler = getAssembler();
if (null == assembler) {
throw new Exception("Assembler is not available for Auto-Deployment of: " + appPath);
}
assembler.createApplication(appInfo);
// war can be unpacked so it changes the last modified time
files.get(appPath).setModified(getLastModifiedInDir(new File(appPath)));
} catch (final Exception e) {
logger.error("Failed Auto-Deployment of: " + appPath, e);
}
return true;
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class ConfigurationFactory method configureApplication.
public AppInfo configureApplication(final File jarFile) throws OpenEJBException {
logger.debug("Beginning load: " + jarFile.getAbsolutePath());
try {
final AppModule appModule = deploymentLoader.load(jarFile, null);
final AppInfo appInfo = configureApplication(appModule);
// this is clean up in Assembler for safety and TomcatWebAppBuilder when used
if (!appModule.getWebModules().isEmpty()) {
for (final WebAppInfo info : appInfo.webApps) {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
if (ejbModule.getModuleId().equals(info.moduleId) && ejbModule.getFinder() != null) {
appInfo.properties.put(info, ejbModule);
}
}
}
}
// TODO This is temporary -- we need to do this in AppInfoBuilder
appInfo.paths.add(appInfo.path);
appInfo.paths.add(jarFile.getAbsolutePath());
return appInfo;
} catch (final ValidationFailedException e) {
// DO not include the stacktrace in the message
logger.warning("configureApplication.loadFailed", jarFile.getAbsolutePath(), e.getMessage());
throw e;
} catch (final OpenEJBException e) {
// DO NOT REMOVE THE EXCEPTION FROM THIS LOG MESSAGE
// removing this message causes NO messages to be printed when embedded
logger.warning("configureApplication.loadFailed", e, jarFile.getAbsolutePath(), e.getMessage());
throw e;
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class HibernateTest method checkEmIsHibernateOne.
// using an internal lookup because in tomee embedded new InitialContext() is not guaranteed
@Test
public void checkEmIsHibernateOne() throws Exception {
AppInfo info = null;
for (final AppInfo app : SystemInstance.get().getComponent(Assembler.class).getDeployedApplications()) {
if (app.appId.endsWith("hibernate-app")) {
info = app;
break;
}
}
assertNotNull(info);
final EntityManagerFactory emf = (EntityManagerFactory) SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext().lookup(Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT + info.persistenceUnits.iterator().next().id);
assertTrue(((ReloadableEntityManagerFactory) emf).getDelegate().getClass().getName().startsWith("org.hibernate."));
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class JMXDeployer method getDeployedApplications.
@ManagedAttribute
@Description("List available applications")
public String[] getDeployedApplications() {
try {
final Collection<AppInfo> apps = deployer().getDeployedApps();
final String[] appsNames = new String[apps.size()];
int i = 0;
for (final AppInfo info : apps) {
appsNames[i++] = info.path;
}
return appsNames;
} catch (final Exception e) {
return new String[] { "ERR:" + e.getMessage() };
}
}
Aggregations