private EjbModule extractModule(final StandardContext standardContext, final AppInfo appInfo) { for (final WebAppInfo app : appInfo.webApps) { if (app.path != null && warPath(standardContext).equals(rootPath(new File(app.path)))) { // see org.apache.openejb.config.ConfigurationFactory.configureApplication(java.io.File) return EjbModule.class.cast(appInfo.properties.remove(app)); } } return null; }
/** * {@inheritDoc} */ @Override public synchronized void afterStop(final StandardServer standardServer) { // clean ear based webapps after shutdown for (final ContextInfo contextInfo : infos.values()) { if (contextInfo != null && contextInfo.deployer != null) { final StandardContext standardContext = contextInfo.standardContext; final HostConfig deployer = contextInfo.deployer; deployer.unmanageApp(standardContext.getPath()); final File realPath = Contexts.warPath(standardContext); if (realPath != null) { deleteDir(realPath); } } } TomcatLoader.destroy(); }
/** * Creates an openejb {@link AppModule} instance * from given tomcat context. * * @param standardContext tomcat context instance * @return a openejb application module */ private AppModule loadApplication(final StandardContext standardContext) { // don't use getId since the app id shouldnt get the host (jndi) // final TomcatDeploymentLoader tomcatDeploymentLoader = new TomcatDeploymentLoader(standardContext, getId(standardContext)); String id = standardContext.getName(); if (id.startsWith("/")) { id = id.substring(1); } final TomcatDeploymentLoader tomcatDeploymentLoader = new TomcatDeploymentLoader(standardContext, id); final AppModule appModule; try { appModule = tomcatDeploymentLoader.load(Contexts.warPath(standardContext), configuredClasspath(standardContext)); } catch (final OpenEJBException e) { throw new TomEERuntimeException(e); } // create the web module loadWebModule(appModule, standardContext); return appModule; }
public void setFinderOnContextConfig(final StandardContext standardContext, final AppModule appModule) { final OpenEJBContextConfig openEJBContextConfig = findOpenEJBContextConfig(standardContext); if (openEJBContextConfig != null) { for (final EjbModule ejbModule : appModule.getEjbModules()) { if (ejbModule.getFile() != null && warPath(standardContext).equals(rootPath(ejbModule.getFile()))) { openEJBContextConfig.finder(ejbModule.getFinder(), ejbModule.getClassLoader()); break; } } } }
/** * {@inheritDoc} */ @Override public void undeployWebApps(final AppInfo appInfo) throws Exception { final String version = appVersion(appInfo); for (final WebAppInfo webApp : appInfo.webApps) { final ContextInfo contextInfo = getContextInfo(webApp.host, webApp.contextRoot, version); if (contextInfo != null) { final StandardContext standardContext = contextInfo.standardContext; if (!appInfo.webAppAlone || !appInfo.properties.containsKey("tomee.destroying")) { undeploy(standardContext, contextInfo); final File extracted = Contexts.warPath(standardContext); if (isExtracted(extracted)) { deleteDir(extracted); } removeContextInfo(standardContext); } } } }
@Override protected void startInternal() throws LifecycleException { if (getClassLoader() != null) { final TomEEWebappClassLoader webappClassLoader = TomEEWebappClassLoader.class.cast(getClassLoader()); if (webappClassLoader.isStopped()) { webappClassLoader.internalStop(); } } final Context context = getContext(); ClassLoaderConfigurer configurer = ClassLoaderUtil.configurer(context.getName()); // WEB-INF/jars.xml final File war = Contexts.warPath(Context.class.cast(context)); final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME); final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml); if (configurerTxt != null) { configurer = new CompositeClassLoaderConfigurer(configurer, configurerTxt); } TomEEWebappClassLoader.initContext(configurer); TomEEWebappClassLoader.initContext(context); try { super.startInternal(); } finally { TomEEWebappClassLoader.cleanContext(); } if (forceSkip != null && WebAppFirstEarClassLoader.class.isInstance(getClassLoader())) { WebAppFirstEarClassLoader.class.cast(getClassLoader()).setForceSkip(forceSkip.split(" *, *")); } }
final File war = Contexts.warPath(CONTEXT.get()); final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME); final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml);
File warFile = Contexts.warPath(standardContext); if (!warFile.exists()) { return;