Search in sources :

Example 36 with Service

use of org.apache.catalina.Service in project tomee by apache.

the class OpenEJBListener method tryToFindAndExtractWar.

private static File tryToFindAndExtractWar(final StandardServer source) {
    if (System.getProperties().containsKey("openejb.war")) {
        return new File(System.getProperty("openejb.war"));
    }
    for (final Service service : source.findServices()) {
        final Container container = service.getContainer();
        if (container instanceof StandardEngine) {
            final StandardEngine engine = (StandardEngine) container;
            for (final Container child : engine.findChildren()) {
                if (child instanceof StandardHost) {
                    final StandardHost host = (StandardHost) child;
                    final File base = hostDir(System.getProperty("catalina.base"), host.getAppBase());
                    final File[] files = base.listFiles();
                    if (files != null) {
                        for (final File file : files) {
                            if (isTomEEWar(file)) {
                                return file;
                            }
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) Service(org.apache.catalina.Service) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 37 with Service

use of org.apache.catalina.Service in project tomee by apache.

the class OpenEJBListener method findOpenEjbWar.

private static File findOpenEjbWar() {
    // in Tomcat 5.5 the OpenEjb war is in the server/webapps director
    final String catalinaBase = System.getProperty("catalina.base");
    final File serverWebapps = new File(catalinaBase, "server/webapps");
    File openEjbWar = findOpenEjbWar(serverWebapps);
    if (openEjbWar != null) {
        return openEjbWar;
    }
    try {
        // scan all hosts directories
        for (final Service service : TomcatHelper.getServer().findServices()) {
            final Container container = service.getContainer();
            if (container instanceof StandardEngine) {
                final StandardEngine engine = (StandardEngine) container;
                for (final Container child : engine.findChildren()) {
                    if (child instanceof StandardHost) {
                        final StandardHost host = (StandardHost) child;
                        final File hostDir = hostDir(catalinaBase, host.getAppBase());
                        openEjbWar = findOpenEjbWar(hostDir);
                        if (openEjbWar != null) {
                            return openEjbWar;
                        } else {
                            return findOpenEjbWar(host);
                        }
                    }
                }
            }
        }
    } catch (final Exception e) {
        LOGGER.log(Level.WARNING, "OpenEJBListener.findOpenEjbWar: " + e.getMessage());
    }
    return null;
}
Also used : Container(org.apache.catalina.Container) StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) Service(org.apache.catalina.Service) JarFile(java.util.jar.JarFile) File(java.io.File) IOException(java.io.IOException)

Example 38 with Service

use of org.apache.catalina.Service in project tomee by apache.

the class GlobalListenerSupport method start.

/**
 * Starts operation.
 */
public void start() {
    // hook the hosts so we get notified before contexts are started
    standardServer.addPropertyChangeListener(this);
    standardServer.addLifecycleListener(this);
    for (final Service service : standardServer.findServices()) {
        serviceAdded(service);
    }
}
Also used : Service(org.apache.catalina.Service)

Example 39 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ThreadLocalLeakPreventionListener method registerListenersForServer.

private void registerListenersForServer(Server server) {
    for (Service service : server.findServices()) {
        Engine engine = (Engine) service.getContainer();
        if (engine != null) {
            engine.addContainerListener(this);
            registerListenersForEngine(engine);
        }
    }
}
Also used : Service(org.apache.catalina.Service) Engine(org.apache.catalina.Engine)

Example 40 with Service

use of org.apache.catalina.Service in project tomcat70 by apache.

the class ApplicationContext method populateSessionTrackingModes.

private void populateSessionTrackingModes() {
    // URL re-writing is always enabled by default
    defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
    if (context.getCookies()) {
        defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
        supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
    }
    // SSL not enabled by default as it can only used on its own
    // Context > Host > Engine > Service
    Service s = ((Engine) context.getParent().getParent()).getService();
    Connector[] connectors = s.findConnectors();
    // Need at least one SSL enabled connector to use the SSL session ID.
    for (Connector connector : connectors) {
        if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
            supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
            break;
        }
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) Service(org.apache.catalina.Service) Engine(org.apache.catalina.Engine)

Aggregations

Service (org.apache.catalina.Service)62 StandardService (org.apache.catalina.core.StandardService)25 Engine (org.apache.catalina.Engine)20 Connector (org.apache.catalina.connector.Connector)20 StandardEngine (org.apache.catalina.core.StandardEngine)16 ObjectName (javax.management.ObjectName)13 StandardHost (org.apache.catalina.core.StandardHost)12 Container (org.apache.catalina.Container)8 Executor (org.apache.catalina.Executor)8 Server (org.apache.catalina.Server)8 MBeanServer (javax.management.MBeanServer)7 InstanceNotFoundException (javax.management.InstanceNotFoundException)6 MBeanException (javax.management.MBeanException)6 Host (org.apache.catalina.Host)6 File (java.io.File)5 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)5 RuntimeOperationsException (javax.management.RuntimeOperationsException)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 StandardContext (org.apache.catalina.core.StandardContext)5 JarFile (java.util.jar.JarFile)3