Search in sources :

Example 51 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 52 with Service

use of org.apache.catalina.Service in project spring-boot by spring-projects.

the class TomcatServletWebServerFactoryTests method tomcatAdditionalConnectors.

@Test
void tomcatAdditionalConnectors() {
    TomcatServletWebServerFactory factory = getFactory();
    Connector[] connectors = new Connector[4];
    Arrays.setAll(connectors, (i) -> new Connector());
    factory.addAdditionalTomcatConnectors(connectors);
    this.webServer = factory.getWebServer();
    Map<Service, Connector[]> connectorsByService = ((TomcatWebServer) this.webServer).getServiceConnectors();
    assertThat(connectorsByService.values().iterator().next()).hasSize(connectors.length + 1);
}
Also used : Connector(org.apache.catalina.connector.Connector) Service(org.apache.catalina.Service) Test(org.junit.jupiter.api.Test)

Example 53 with Service

use of org.apache.catalina.Service in project spring-boot by spring-projects.

the class TomcatReactiveWebServerFactoryTests method tomcatAdditionalConnectors.

@Test
void tomcatAdditionalConnectors() {
    TomcatReactiveWebServerFactory factory = getFactory();
    Connector[] connectors = new Connector[4];
    Arrays.setAll(connectors, (i) -> new Connector());
    factory.addAdditionalTomcatConnectors(connectors);
    this.webServer = factory.getWebServer(mock(HttpHandler.class));
    Map<Service, Connector[]> connectorsByService = ((TomcatWebServer) this.webServer).getServiceConnectors();
    assertThat(connectorsByService.values().iterator().next()).hasSize(connectors.length + 1);
}
Also used : Connector(org.apache.catalina.connector.Connector) Service(org.apache.catalina.Service) Test(org.junit.jupiter.api.Test)

Example 54 with Service

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

the class StandardServer method stopInternal.

/**
 * Stop nested components ({@link Service}s) and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that needs to be reported
 */
@Override
protected void stopInternal() throws LifecycleException {
    setState(LifecycleState.STOPPING);
    if (monitorFuture != null) {
        monitorFuture.cancel(true);
        monitorFuture = null;
    }
    if (periodicLifecycleEventFuture != null) {
        periodicLifecycleEventFuture.cancel(false);
        periodicLifecycleEventFuture = null;
    }
    fireLifecycleEvent(CONFIGURE_STOP_EVENT, null);
    // Stop our defined Services
    for (Service service : services) {
        service.stop();
    }
    globalNamingResources.stop();
    stopAwait();
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(org.apache.catalina.Service)

Example 55 with Service

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

the class StandardServer method initInternal.

/**
 * Invoke a pre-startup initialization. This is used to allow connectors
 * to bind to restricted ports under Unix operating environments.
 */
@Override
protected void initInternal() throws LifecycleException {
    super.initInternal();
    // Initialize utility executor
    reconfigureUtilityExecutor(getUtilityThreadsInternal(utilityThreads));
    register(utilityExecutor, "type=UtilityExecutor");
    // Register global String cache
    // Note although the cache is global, if there are multiple Servers
    // present in the JVM (may happen when embedding) then the same cache
    // will be registered under multiple names
    onameStringCache = register(new StringCache(), "type=StringCache");
    // Register the MBeanFactory
    MBeanFactory factory = new MBeanFactory();
    factory.setContainer(this);
    onameMBeanFactory = register(factory, "type=MBeanFactory");
    // Register the naming resources
    globalNamingResources.init();
    // Initialize our defined Services
    for (Service service : services) {
        service.init();
    }
}
Also used : StringCache(org.apache.tomcat.util.buf.StringCache) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Service(org.apache.catalina.Service) MBeanFactory(org.apache.catalina.mbeans.MBeanFactory)

Aggregations

Service (org.apache.catalina.Service)64 StandardService (org.apache.catalina.core.StandardService)25 Connector (org.apache.catalina.connector.Connector)22 Engine (org.apache.catalina.Engine)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