Search in sources :

Example 1 with ALPNClientConnectionFactory

use of org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory in project jetty.project by eclipse.

the class HTTP2Client method doStart.

@Override
protected void doStart() throws Exception {
    if (executor == null)
        setExecutor(new QueuedThreadPool());
    if (scheduler == null)
        setScheduler(new ScheduledExecutorScheduler());
    if (bufferPool == null)
        setByteBufferPool(new MappedByteBufferPool());
    if (connectionFactory == null) {
        HTTP2ClientConnectionFactory h2 = new HTTP2ClientConnectionFactory();
        setClientConnectionFactory((endPoint, context) -> {
            ClientConnectionFactory factory = h2;
            SslContextFactory sslContextFactory = (SslContextFactory) context.get(SslClientConnectionFactory.SSL_CONTEXT_FACTORY_CONTEXT_KEY);
            if (sslContextFactory != null) {
                ALPNClientConnectionFactory alpn = new ALPNClientConnectionFactory(getExecutor(), h2, getProtocols());
                factory = new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), alpn);
            }
            return factory.newConnection(endPoint, context);
        });
    }
    if (selector == null) {
        selector = newSelectorManager();
        addBean(selector);
    }
    selector.setConnectTimeout(getConnectTimeout());
    super.doStart();
}
Also used : MappedByteBufferPool(org.eclipse.jetty.io.MappedByteBufferPool) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) SslClientConnectionFactory(org.eclipse.jetty.io.ssl.SslClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory) ClientConnectionFactory(org.eclipse.jetty.io.ClientConnectionFactory) SslClientConnectionFactory(org.eclipse.jetty.io.ssl.SslClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory)

Example 2 with ALPNClientConnectionFactory

use of org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory in project jetty.project by eclipse.

the class HttpClientTransportOverHTTP2 method newConnection.

@Override
public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException {
    endPoint.setIdleTimeout(httpClient.getIdleTimeout());
    ClientConnectionFactory factory = connectionFactory;
    HttpDestinationOverHTTP2 destination = (HttpDestinationOverHTTP2) context.get(HTTP_DESTINATION_CONTEXT_KEY);
    ProxyConfiguration.Proxy proxy = destination.getProxy();
    boolean ssl = proxy == null ? HttpScheme.HTTPS.is(destination.getScheme()) : proxy.isSecure();
    if (ssl && isUseALPN())
        factory = new ALPNClientConnectionFactory(client.getExecutor(), factory, client.getProtocols());
    return factory.newConnection(endPoint, context);
}
Also used : ProxyConfiguration(org.eclipse.jetty.client.ProxyConfiguration) HTTP2ClientConnectionFactory(org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory) ClientConnectionFactory(org.eclipse.jetty.io.ClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory)

Aggregations

ALPNClientConnectionFactory (org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory)2 ClientConnectionFactory (org.eclipse.jetty.io.ClientConnectionFactory)2 ProxyConfiguration (org.eclipse.jetty.client.ProxyConfiguration)1 HTTP2ClientConnectionFactory (org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory)1 MappedByteBufferPool (org.eclipse.jetty.io.MappedByteBufferPool)1 SslClientConnectionFactory (org.eclipse.jetty.io.ssl.SslClientConnectionFactory)1 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 ScheduledExecutorScheduler (org.eclipse.jetty.util.thread.ScheduledExecutorScheduler)1