Search in sources :

Example 66 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class ReplicatedWebMethodSessionStrategyBuilder method initializePersistenceStrategy.

public void initializePersistenceStrategy(Context ctx, SessionManager smBean, ServerConfigLookup serverConfigLookup) {
    super.initializePersistenceStrategy(ctx, smBean, serverConfigLookup);
    // super.setPassedInPersistenceType("replicated");
    if (this.getPersistenceScope().equals("session")) {
        setupReplicationWebEventPersistentManager(SimpleMetadata.class, new FullSessionFactory(), new ReplicationStore(ioUtils), ctx, serverConfigLookup);
    } else if (this.getPersistenceScope().equals("modified-session")) {
        setupReplicationWebEventPersistentManager(SimpleMetadata.class, new ModifiedSessionFactory(), new ReplicationStore(ioUtils), ctx, serverConfigLookup);
    } else if (this.getPersistenceScope().equals("modified-attribute")) {
        setupReplicationWebEventPersistentManager(CompositeMetadata.class, new ModifiedAttributeSessionFactory(), new ReplicationAttributeStore(ioUtils), ctx, serverConfigLookup);
    } else {
        throw new IllegalArgumentException(this.getPersistenceScope());
    }
    HASessionStoreValve haValve = new HASessionStoreValve();
    StandardContext stdCtx = (StandardContext) ctx;
    stdCtx.addValve((GlassFishValve) haValve);
}
Also used : StandardContext(org.apache.catalina.core.StandardContext) SimpleMetadata(org.glassfish.ha.store.util.SimpleMetadata)

Example 67 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class ReplicationStore method getUniqueId.

protected long getUniqueId() {
    long uniqueId = 0L;
    Container container = this.manager.getContainer();
    if (container instanceof StandardContext) {
        StandardContext ctx = (StandardContext) container;
        uniqueId = ctx.getUniqueId();
    }
    return uniqueId;
}
Also used : Container(org.apache.catalina.Container) StandardContext(org.apache.catalina.core.StandardContext)

Example 68 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class WebappLoader method init.

public void init() {
    initialized = true;
    if (oname == null) {
        // not registered yet - standalone or API
        if (container instanceof StandardContext) {
            // Register ourself. The container must be a webapp
            try {
                StandardContext ctx = (StandardContext) container;
                String path = ctx.getEncodedPath();
                if (path.equals("")) {
                    path = "/";
                }
                oname = new ObjectName(ctx.getEngineName() + ":type=Loader,path=" + path + ",host=" + ctx.getParent().getName());
                controller = oname;
            } catch (Exception e) {
                log.log(Level.SEVERE, LogFacade.REGISTERING_LOADER_EXCEPTION, e);
            }
        }
    }
/*
        if( container == null ) {
            // JMX created the loader
            // TODO
        }
        */
}
Also used : StandardContext(org.apache.catalina.core.StandardContext) NamingException(javax.naming.NamingException) PrivilegedActionException(java.security.PrivilegedActionException) MalformedURLException(java.net.MalformedURLException) ObjectName(javax.management.ObjectName)

Example 69 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class WebContainer method updateJvmRoute.

public void updateJvmRoute(HttpService httpService, String jvmOption) {
    String jvmRoute = null;
    if (jvmOption.contains("{") && jvmOption.contains("}")) {
        // Look up system-property
        jvmOption = jvmOption.substring(jvmOption.indexOf('{') + 1, jvmOption.indexOf('}'));
        jvmRoute = server.getSystemPropertyValue(jvmOption);
        if (jvmRoute == null) {
            // Try to get it from System property if it exists
            jvmRoute = System.getProperty(jvmOption);
        }
    } else if (jvmOption.contains("=")) {
        jvmRoute = jvmOption.substring(jvmOption.indexOf('=') + 1);
    }
    engine.setJvmRoute(jvmRoute);
    for (com.sun.enterprise.config.serverbeans.VirtualServer vsBean : httpService.getVirtualServer()) {
        VirtualServer vs = (VirtualServer) engine.findChild(vsBean.getId());
        for (Container context : vs.findChildren()) {
            if (context instanceof StandardContext) {
                ((StandardContext) context).setJvmRoute(jvmRoute);
            }
        }
    }
    for (Connector connector : _embedded.getConnectors()) {
        connector.setJvmRoute(jvmRoute);
    }
    logger.log(Level.FINE, LogFacade.JVM_ROUTE_UPDATED, jvmRoute);
}
Also used : PECoyoteConnector(com.sun.enterprise.web.connector.coyote.PECoyoteConnector) Connector(org.apache.catalina.Connector) Container(org.apache.catalina.Container) StandardContext(org.apache.catalina.core.StandardContext)

Example 70 with StandardContext

use of org.apache.catalina.core.StandardContext in project sonarqube by SonarSource.

the class TomcatContexts method addContext.

private static StandardContext addContext(Tomcat tomcat, String contextPath, File dir) {
    try {
        StandardContext context = (StandardContext) tomcat.addWebapp(contextPath, dir.getAbsolutePath());
        context.setClearReferencesHttpClientKeepAliveThread(false);
        context.setClearReferencesStopThreads(false);
        context.setClearReferencesStopTimerThreads(false);
        context.setClearReferencesStopTimerThreads(false);
        context.setAntiResourceLocking(false);
        context.setReloadable(false);
        context.setUseHttpOnly(true);
        context.setTldValidation(false);
        context.setXmlValidation(false);
        context.setXmlNamespaceAware(false);
        context.setUseNaming(false);
        context.setDelegate(true);
        context.setJarScanner(new NullJarScanner());
        context.setAllowCasualMultipartParsing(true);
        context.setCookies(false);
        // disable JSP and WebSocket support
        context.setContainerSciFilter("org.apache.tomcat.websocket.server.WsSci|org.apache.jasper.servlet.JasperInitializer");
        return context;
    } catch (Exception e) {
        throw new IllegalStateException("Fail to configure webapp from " + dir, e);
    }
}
Also used : StandardContext(org.apache.catalina.core.StandardContext) IOException(java.io.IOException) MessageException(org.sonar.api.utils.MessageException)

Aggregations

StandardContext (org.apache.catalina.core.StandardContext)181 File (java.io.File)72 Tomcat (org.apache.catalina.startup.Tomcat)64 Test (org.junit.Test)52 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)41 Context (org.apache.catalina.Context)32 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)31 StandardHost (org.apache.catalina.core.StandardHost)25 IOException (java.io.IOException)22 Host (org.apache.catalina.Host)18 MalformedURLException (java.net.MalformedURLException)16 JarFile (java.util.jar.JarFile)16 ServletContext (javax.servlet.ServletContext)16 StandardRoot (org.apache.catalina.webresources.StandardRoot)16 URL (java.net.URL)13 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)12 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)12 HashMap (java.util.HashMap)12 List (java.util.List)12 Container (org.apache.catalina.Container)12