Search in sources :

Example 61 with Connector

use of org.apache.catalina.connector.Connector in project sonarqube by SonarSource.

the class TomcatConnectorsTest method bind_to_all_addresses_by_default.

@Test
public void bind_to_all_addresses_by_default() {
    Properties p = new Properties();
    p.setProperty("sonar.web.port", "9000");
    TomcatConnectors.configure(tomcat, new Props(p));
    verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {

        @Override
        public boolean matches(Object o) {
            Connector c = (Connector) o;
            return c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("0.0.0.0");
        }
    }));
}
Also used : Connector(org.apache.catalina.connector.Connector) ArgumentMatcher(org.mockito.ArgumentMatcher) Properties(java.util.Properties) Props(org.sonar.process.Props) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 62 with Connector

use of org.apache.catalina.connector.Connector in project sonarqube by SonarSource.

the class TomcatConnectors method newHttpConnector.

private static Connector newHttpConnector(Props props) {
    // Not named "sonar.web.http.port" to keep backward-compatibility
    int port = props.valueAsInt("sonar.web.port", 9000);
    if (port < UNDEFINED_PORT) {
        throw new IllegalStateException(format("HTTP port '%s' is invalid", port));
    }
    Connector connector = newConnector(props, HTTP_PROTOCOL, "http");
    configureMaxHttpHeaderSize(connector);
    connector.setPort(port);
    connector.setMaxPostSize(MAX_POST_SIZE);
    return connector;
}
Also used : Connector(org.apache.catalina.connector.Connector)

Example 63 with Connector

use of org.apache.catalina.connector.Connector in project pinpoint by naver.

the class ConnectorInitializeInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    if (target instanceof Connector) {
        final Connector connector = (Connector) target;
        ServerMetaDataHolder holder = this.traceContext.getServerMetaDataHolder();
        holder.addConnector(connector.getProtocol(), connector.getPort());
        holder.notifyListeners();
    }
}
Also used : Connector(org.apache.catalina.connector.Connector) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder)

Example 64 with Connector

use of org.apache.catalina.connector.Connector in project async-http-client by AsyncHttpClient.

the class WebDavBasicTest method setUpGlobal.

@BeforeClass(alwaysRun = true)
public void setUpGlobal() throws Exception {
    embedded = new Embedded();
    String path = new File(".").getAbsolutePath();
    embedded.setCatalinaHome(path);
    Engine engine = embedded.createEngine();
    engine.setDefaultHost("localhost");
    Host host = embedded.createHost("localhost", path);
    engine.addChild(host);
    Context c = embedded.createContext("/", path);
    c.setReloadable(false);
    Wrapper w = c.createWrapper();
    w.addMapping("/*");
    w.setServletClass(org.apache.catalina.servlets.WebdavServlet.class.getName());
    w.addInitParameter("readonly", "false");
    w.addInitParameter("listings", "true");
    w.setLoadOnStartup(0);
    c.addChild(w);
    host.addChild(c);
    Connector connector = embedded.createConnector("localhost", 0, Http11NioProtocol.class.getName());
    connector.setContainer(host);
    embedded.addEngine(engine);
    embedded.addConnector(connector);
    embedded.start();
    port1 = connector.getLocalPort();
}
Also used : Context(org.apache.catalina.Context) Wrapper(org.apache.catalina.Wrapper) Connector(org.apache.catalina.connector.Connector) Http11NioProtocol(org.apache.coyote.http11.Http11NioProtocol) Host(org.apache.catalina.Host) Embedded(org.apache.catalina.startup.Embedded) File(java.io.File) Engine(org.apache.catalina.Engine) BeforeClass(org.testng.annotations.BeforeClass)

Example 65 with Connector

use of org.apache.catalina.connector.Connector in project tomee by apache.

the class TomcatRsRegistry method address.

private static String address(final Collection<Connector> connectors, final String host, final String path) {
    final List<String> addresses = new ArrayList<>();
    for (final Connector connector : connectors) {
        final URI address;
        try {
            address = new URI(connector.getScheme(), null, host, connector.getPort(), path, null, null);
        } catch (final Exception e) {
            // just an URI problem normally...shouldn't occur
            LOGGER.error("can't add container for path " + path, e);
            continue;
        }
        addresses.add(address.toString());
    }
    return HttpUtil.selectSingleAddress(addresses);
}
Also used : Connector(org.apache.catalina.connector.Connector) ArrayList(java.util.ArrayList) URI(java.net.URI)

Aggregations

Connector (org.apache.catalina.connector.Connector)70 Test (org.junit.Test)16 Service (org.apache.catalina.Service)15 File (java.io.File)12 Tomcat (org.apache.catalina.startup.Tomcat)11 Properties (java.util.Properties)8 Context (org.apache.catalina.Context)7 HashMap (java.util.HashMap)6 Engine (org.apache.catalina.Engine)6 SSLHostConfig (org.apache.tomcat.util.net.SSLHostConfig)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 StandardService (org.apache.catalina.core.StandardService)5 URI (java.net.URI)4 Executor (org.apache.catalina.Executor)4 LifecycleException (org.apache.catalina.LifecycleException)4 Server (org.apache.catalina.Server)4 Http2Protocol (org.apache.coyote.http2.Http2Protocol)4 ObjectName (javax.management.ObjectName)3