Search in sources :

Example 6 with ContainerLifeCycle

use of org.eclipse.jetty.util.component.ContainerLifeCycle in project blade by biezhi.

the class SslClientConnectionFactory method customize.

@Override
public Connection customize(Connection connection, Map<String, Object> context) {
    if (connection instanceof SslConnection) {
        SslConnection sslConnection = (SslConnection) connection;
        sslConnection.setRenegotiationAllowed(sslContextFactory.isRenegotiationAllowed());
        ContainerLifeCycle connector = (ContainerLifeCycle) context.get(ClientConnectionFactory.CONNECTOR_CONTEXT_KEY);
        connector.getBeans(SslHandshakeListener.class).forEach(sslConnection::addHandshakeListener);
    }
    return ClientConnectionFactory.super.customize(connection, context);
}
Also used : ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle)

Example 7 with ContainerLifeCycle

use of org.eclipse.jetty.util.component.ContainerLifeCycle in project blade by biezhi.

the class ClientConnectionFactory method customize.

public default default Connection customize(Connection connection, Map<String, Object> context) {
    ContainerLifeCycle connector = (ContainerLifeCycle) context.get(CONNECTOR_CONTEXT_KEY);
    connector.getBeans(Connection.Listener.class).forEach(connection::addListener);
    return connection;
}
Also used : ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle)

Example 8 with ContainerLifeCycle

use of org.eclipse.jetty.util.component.ContainerLifeCycle in project dropwizard by dropwizard.

the class DefaultServerFactory method buildAdminConnectors.

private List<Connector> buildAdminConnectors(MetricRegistry metricRegistry, Server server) {
    // threadpool is shared between all the connectors, so it should be managed by the server instead of the
    // individual connectors
    final QueuedThreadPool threadPool = new QueuedThreadPool(adminMaxThreads, adminMinThreads);
    threadPool.setName("dw-admin");
    server.addBean(threadPool);
    final List<Connector> connectors = new ArrayList<>();
    for (ConnectorFactory factory : adminConnectors) {
        final Connector connector = factory.build(server, metricRegistry, "admin", threadPool);
        if (connector instanceof ContainerLifeCycle) {
            ((ContainerLifeCycle) connector).unmanage(threadPool);
        }
        connectors.add(connector);
    }
    return connectors;
}
Also used : Connector(org.eclipse.jetty.server.Connector) HttpConnectorFactory(io.dropwizard.jetty.HttpConnectorFactory) ConnectorFactory(io.dropwizard.jetty.ConnectorFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ArrayList(java.util.ArrayList) ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle)

Example 9 with ContainerLifeCycle

use of org.eclipse.jetty.util.component.ContainerLifeCycle in project dropwizard by dropwizard.

the class LifecycleEnvironmentTest method managesManagedObjects.

@Test
public void managesManagedObjects() throws Exception {
    final Managed managed = mock(Managed.class);
    environment.manage(managed);
    final ContainerLifeCycle container = new ContainerLifeCycle();
    environment.attach(container);
    final Object bean = ImmutableList.copyOf(container.getBeans()).get(0);
    assertThat(bean).isInstanceOf(JettyManaged.class);
    final JettyManaged jettyManaged = (JettyManaged) bean;
    assertThat(jettyManaged.getManaged()).isEqualTo(managed);
}
Also used : JettyManaged(io.dropwizard.lifecycle.JettyManaged) ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle) JettyManaged(io.dropwizard.lifecycle.JettyManaged) Managed(io.dropwizard.lifecycle.Managed) Test(org.junit.Test)

Example 10 with ContainerLifeCycle

use of org.eclipse.jetty.util.component.ContainerLifeCycle in project jetty.project by eclipse.

the class ClientConnectionFactory method customize.

public default default Connection customize(Connection connection, Map<String, Object> context) {
    ContainerLifeCycle connector = (ContainerLifeCycle) context.get(CONNECTOR_CONTEXT_KEY);
    connector.getBeans(Connection.Listener.class).forEach(connection::addListener);
    return connection;
}
Also used : ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle)

Aggregations

ContainerLifeCycle (org.eclipse.jetty.util.component.ContainerLifeCycle)12 Test (org.junit.Test)2 Managed (com.acme.Managed)1 ConnectorFactory (io.dropwizard.jetty.ConnectorFactory)1 HttpConnectorFactory (io.dropwizard.jetty.HttpConnectorFactory)1 JettyManaged (io.dropwizard.lifecycle.JettyManaged)1 Managed (io.dropwizard.lifecycle.Managed)1 ArrayList (java.util.ArrayList)1 SSLEngine (javax.net.ssl.SSLEngine)1 SslConnection (org.eclipse.jetty.io.ssl.SslConnection)1 SslHandshakeListener (org.eclipse.jetty.io.ssl.SslHandshakeListener)1 Connector (org.eclipse.jetty.server.Connector)1 Container (org.eclipse.jetty.util.component.Container)1 LifeCycle (org.eclipse.jetty.util.component.LifeCycle)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 WebSocketContainerScope (org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope)1 Before (org.junit.Before)1