if (!file.isAbsolute()) { if (container == null) { docBase = new File(engineBase(standardContext), standardContext.getDocBase()); } else { final String appBase = ((Host) container).getAppBase(); file = new File(appBase); if (!file.isAbsolute()) { file = new File(engineBase(standardContext), appBase); return oldRealWarPath(standardContext);
/** * Gets id of the context. Context id * is host name + context root name. * * @param standardContext context instance * @return id of the context */ private String getId(final StandardContext standardContext) { return getId(Contexts.getHostname(standardContext), standardContext.getPath(), standardContext.getWebappVersion()); }
public static File warPath(final Context standardContext) { final File file = realWarPath(standardContext); if (file == null) { return null; } final String name = file.getName(); if (!file.isDirectory() && name.endsWith(".war")) { final File extracted = new File(file.getParentFile(), name.substring(0, name.length() - ".war".length())); if (extracted.exists()) { try { return extracted.getCanonicalFile(); } catch (final IOException e) { return extracted; } } } try { return file.getCanonicalFile(); } catch (final IOException e) { return file; } }
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; }
+ Contexts.getHostname(standardContext).replace("_", hosts.getDefaultHost()) + " -> " + finalName(standardContext.getPath())); File warFile = Contexts.warPath(standardContext); if (!warFile.exists()) { return;
/** * {@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; }
final String hostname = Contexts.getHostname(standardContext); if (hostname != null && !"_".equals(hostname)) { webApp.host = hostname;
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; } } } }
private WebBeansContext getWebBeansContext(final ContextInfo contextInfo) { final AppContext appContext = getContainerSystem().getAppContext(contextInfo.appInfo.appId); if (appContext == null) { return null; } WebBeansContext webBeansContext = appContext.getWebBeansContext(); if (webBeansContext == null) { return null; } for (final WebContext web : appContext.getWebContexts()) { final String stdName = removeFirstSlashAndWar(contextInfo.standardContext.getName()); if (stdName == null) { continue; } final String name = removeFirstSlashAndWar(web.getContextRoot()); if (stdName.equals(name)) { webBeansContext = web.getWebbeansContext(); if (Contexts.getHostname(contextInfo.standardContext).equals(web.getHost())) { break; } // else loop hoping to find a better matching } } if (webBeansContext == null) { webBeansContext = appContext.getWebBeansContext(); } return webBeansContext; }
/** * {@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); } } } }
final String hostname = org.apache.tomee.catalina.Contexts.getHostname(standardContext); String path = standardContext.findParameter(TomcatWebAppBuilder.OPENEJB_WEBAPP_MODULE_ID); if (path == null) { // standardContext not created by OpenEJB
@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(" *, *")); } }
contextInfo = addContextInfo(Contexts.getHostname(standardContext), standardContext); if (webAppInfo == null) { webAppInfo = w; } else if (w.host != null && w.host.equals(Contexts.getHostname(standardContext))) { webAppInfo = w; webAppInfo.host = Contexts.getHostname(standardContext); webAppInfo.contextRoot = standardContext.getPath();
final File war = Contexts.warPath(CONTEXT.get()); final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME); final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml);
webModule.setHost(Contexts.getHostname(standardContext));