protected void prepareContext(Host host, TomcatHttpHandlerAdapter servlet) { File docBase = createTempDir("tomcat-docbase"); TomcatEmbeddedContext context = new TomcatEmbeddedContext(); context.setPath(""); context.setDocBase(docBase.getAbsolutePath()); context.addLifecycleListener(new Tomcat.FixContextListener()); context.setParentClassLoader(ClassUtils.getDefaultClassLoader()); skipAllTldScanning(context); WebappLoader loader = new WebappLoader(context.getParentClassLoader()); loader.setLoaderClass(TomcatEmbeddedWebappClassLoader.class.getName()); loader.setDelegate(true); context.setLoader(loader); Tomcat.addServlet(context, "httpHandlerServlet", servlet).setAsyncSupported(true); context.addServletMappingDecoded("/", "httpHandlerServlet"); host.addChild(context); configureContext(context); }
localHost.addChild(rootContext);
localHost.addChild(rootContext);
host.addChild(context); configureContext(context, initializersToUse); postProcessContext(context);
/** * Set additional contexts. * * @param contexts * Map of contexts * @throws ServletException */ public void setContexts(Map<String, String> contexts) throws ServletException { log.debug("setContexts: {}", contexts.size()); for (Map.Entry<String, String> entry : contexts.entrySet()) { host.addChild(embedded.addWebapp(entry.getKey(), webappFolder + entry.getValue())); } }
/** * Set additional contexts. * * @param contexts * Map of contexts * @throws ServletException */ @Override public void setContexts(Map<String, String> contexts) throws ServletException { log.debug("setContexts: {}", contexts.size()); for (Map.Entry<String, String> entry : contexts.entrySet()) { host.addChild(embedded.addWebapp(entry.getKey(), webappRoot + entry.getValue())); } }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp( Host host, String url, String name, String path ) { Context ctx = new StandardContext(); ctx.setName( name ); ctx.setPath( url ); ctx.setDocBase( path ); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener( ctxCfg ); ctxCfg.setDefaultWebXml( new File( configurationDir, "conf/web.xml" ).getAbsolutePath() ); if ( host == null ) { getHost().addChild( ctx ); } else { host.addChild( ctx ); } return ctx; } }
@Override public void addWebAppContext( final String contextPath, final String location, final boolean cookies) { final Context context = container.createContext(contextPath, location); context.setLoader(webAppLoader); context.setReloadable(true); context.setCookies(cookies); localHost.addChild(context); }
private Callable<Context> createCallableContext(Tomcat tomcat, ComponentConfig.WebappInfo appInfo, Property clusterProp, ContainerConfig.Configuration configuration) { Debug.logInfo("Creating context [" + appInfo.name + "]", module); Host host = prepareHost(tomcat, appInfo.getVirtualHosts()); return () -> { StandardContext context = prepareContext(host, configuration, appInfo, clusterProp); host.addChild(context); return context; }; }
public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
/** * @see #addContext(String, String) */ public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
private void createStaticContext( final Embedded container, Context context, Host host ) { if ( staticContextDocbase != null ) { Context staticContext = container.createContext( staticContextPath, staticContextDocbase ); staticContext.setPrivileged( true ); Wrapper servlet = context.createWrapper(); servlet.setServletClass( DefaultServlet.class.getName() ); servlet.setName( "staticContent" ); staticContext.addChild( servlet ); staticContext.addServletMapping( "/", "staticContent" ); host.addChild( staticContext ); } }
@Override public Context addWebapp(Host host, String contextPath, String docBase, LifecycleListener config) { // quit because of private and unneeded //silence(host, contextPath); final Context ctx = createContext(host, contextPath); ctx.setPath(contextPath); ctx.setDocBase(docBase); ctx.addLifecycleListener(newDefaultWebXmlListener()); // *extension point ctx.setConfigFile(getWebappConfigFile(docBase, contextPath)); ctx.addLifecycleListener(config); if (config instanceof ContextConfig) { // prevent it from looking ( if it finds one - it'll have dup error ) ((ContextConfig) config).setDefaultWebXml(noDefaultWebXmlPath()); } if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp(Host host, String url, String name, String path) { silence(host, url); Context ctx = new StandardContext(); ctx.setName(name); ctx.setPath(url); ctx.setDocBase(path); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp(Host host, String url, String name, String path) { silence(host, url); Context ctx = new StandardContext(); ctx.setName(name); ctx.setPath(url); ctx.setDocBase(path); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp(Host host, String url, String path) { silence(url); Context ctx = new StandardContext(); ctx.setPath( url ); ctx.setDocBase(path); if (defaultRealm == null) { initSimpleAuth(); } ctx.setRealm(defaultRealm); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML"); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }