Search in sources :

Example 31 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);
    }
    if (logger.isLoggable(Level.FINE)) {
        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 32 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 33 with StandardContext

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

the class LoggerBase method createObjectName.

public ObjectName createObjectName() {
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "createObjectName with " + container);
    }
    // register
    try {
        StandardEngine engine = null;
        String suffix = "";
        if (container instanceof StandardEngine) {
            engine = (StandardEngine) container;
        } else if (container instanceof StandardHost) {
            engine = (StandardEngine) container.getParent();
            suffix = ",host=" + container.getName();
        } else if (container instanceof StandardContext) {
            String path = ((StandardContext) container).getPath();
            // add "/" to avoid MalformedObjectName Exception
            if (path.equals("")) {
                path = "/";
            }
            engine = (StandardEngine) container.getParent().getParent();
            suffix = ",path=" + path + ",host=" + container.getParent().getName();
        } else {
            log.log(Level.SEVERE, LogFacade.UNKNOWN_CONTAINER_EXCEPTION);
        }
        if (engine != null) {
            oname = new ObjectName(engine.getDomain() + ":type=Logger" + suffix);
        } else {
            log.log(Level.SEVERE, LogFacade.NULL_ENGINE_EXCEPTION, container);
        }
    } catch (Throwable e) {
        log.log(Level.WARNING, LogFacade.UNABLE_CREATE_OBJECT_NAME_FOR_LOGGER_EXCEPTION, e);
    }
    return oname;
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) ObjectName(javax.management.ObjectName)

Example 34 with StandardContext

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

the class ManagerBase method init.

public void init() {
    if (initialized)
        return;
    initialized = true;
    if (oname == null) {
        try {
            StandardContext ctx = (StandardContext) this.getContainer();
            domain = ctx.getEngineName();
            distributable = ctx.getDistributable();
            StandardHost hst = (StandardHost) ctx.getParent();
            String path = ctx.getEncodedPath();
            if (path.equals("")) {
                path = "/";
            }
            oname = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + hst.getName());
        } catch (Exception e) {
            log.log(Level.SEVERE, LogFacade.ERROR_REGISTERING_EXCEPTION_SEVERE, e);
        }
    }
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "Registering " + oname);
    }
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 35 with StandardContext

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

the class BaseHASession method sync.

public void sync() {
    HttpSessionBindingEvent event = null;
    event = new HttpSessionBindingEvent((HttpSession) this, null, null);
    // Notify special event listeners on sync()
    Manager manager = this.getManager();
    StandardContext stdContext = (StandardContext) manager.getContainer();
    // fire container event
    stdContext.fireContainerEvent("sessionSync", event);
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSession(javax.servlet.http.HttpSession) StandardContext(org.apache.catalina.core.StandardContext) Manager(org.apache.catalina.Manager)

Aggregations

StandardContext (org.apache.catalina.core.StandardContext)91 File (java.io.File)36 Tomcat (org.apache.catalina.startup.Tomcat)24 Context (org.apache.catalina.Context)19 Test (org.junit.Test)19 StandardHost (org.apache.catalina.core.StandardHost)16 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)12 Container (org.apache.catalina.Container)11 Host (org.apache.catalina.Host)11 JarFile (java.util.jar.JarFile)10 IOException (java.io.IOException)9 URL (java.net.URL)9 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)9 HashMap (java.util.HashMap)8 StandardRoot (org.apache.catalina.webresources.StandardRoot)8 ArrayList (java.util.ArrayList)7 List (java.util.List)6 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)6 MalformedURLException (java.net.MalformedURLException)5 ServletContext (javax.servlet.ServletContext)5