use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class SslServerCustomizerTests method whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories.
@Test
@SuppressWarnings("rawtypes")
void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() {
Http2 http2 = new Http2();
http2.setEnabled(true);
Server server = createCustomizedServer(http2);
assertThat(server.getConnectors()).hasSize(1);
List<ConnectionFactory> factories = new ArrayList<>(server.getConnectors()[0].getConnectionFactories());
assertThat(factories).extracting((factory) -> (Class) factory.getClass()).containsExactly(SslConnectionFactory.class, ALPNServerConnectionFactory.class, HTTP2ServerConnectionFactory.class, HttpConnectionFactory.class);
}
use of org.eclipse.jetty.server.ConnectionFactory in project spring-boot by spring-projects.
the class SslServerCustomizerTests method whenHttp2IsNotEnabledServerConnectorHasSslAndHttpConnectionFactories.
@Test
@SuppressWarnings("rawtypes")
void whenHttp2IsNotEnabledServerConnectorHasSslAndHttpConnectionFactories() {
Server server = createCustomizedServer();
assertThat(server.getConnectors()).hasSize(1);
List<ConnectionFactory> factories = new ArrayList<>(server.getConnectors()[0].getConnectionFactories());
assertThat(factories).extracting((factory) -> (Class) factory.getClass()).containsExactly(SslConnectionFactory.class, HttpConnectionFactory.class);
}
use of org.eclipse.jetty.server.ConnectionFactory in project cxf by apache.
the class JettyHTTPServerEngine method createConnectorJetty.
AbstractConnector createConnectorJetty(SslContextFactory sslcf, String hosto, int porto, int major, int minor, final Bus bus) {
final AbstractConnector result;
try {
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(getSendServerVersion());
HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfig);
Collection<ConnectionFactory> connectionFactories = new ArrayList<>();
result = new org.eclipse.jetty.server.ServerConnector(server);
if (tlsServerParameters != null) {
httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
if (!isHttp2Enabled(bus)) {
final SslConnectionFactory scf = new SslConnectionFactory(sslcf, httpFactory.getProtocol());
connectionFactories.add(scf);
} else {
// The ALPN processors are application specific (as per Jetty docs) and are pluggable as
// additional dependency.
final ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
alpn.setDefaultProtocol(httpFactory.getProtocol());
final SslConnectionFactory scf = new SslConnectionFactory(sslcf, alpn.getProtocol());
connectionFactories.add(scf);
connectionFactories.add(alpn);
connectionFactories.add(new HTTP2ServerConnectionFactory(httpConfig));
}
String proto = (major > 9 || (major == 9 && minor >= 3)) ? "SSL" : "SSL-HTTP/1.1";
result.setDefaultProtocol(proto);
} else if (isHttp2Enabled(bus)) {
connectionFactories.add(new HTTP2CServerConnectionFactory(httpConfig));
}
connectionFactories.add(httpFactory);
result.setConnectionFactories(connectionFactories);
if (getMaxIdleTime() > 0) {
result.setIdleTimeout(Long.valueOf(getMaxIdleTime()));
}
} catch (RuntimeException rex) {
throw rex;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
return result;
}
use of org.eclipse.jetty.server.ConnectionFactory in project cxf by apache.
the class JettyHTTPServerEngineFactoryTest method testMakeSureJetty9ConnectorConfigured.
@Test
public void testMakeSureJetty9ConnectorConfigured() throws Exception {
URL config = getClass().getResource("server-engine-factory-jetty9-connector.xml");
bus = new SpringBusFactory().createBus(config, true);
JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
assertNotNull("EngineFactory is not configured.", factory);
JettyHTTPServerEngine engine = factory.createJettyHTTPServerEngine(1234, "http");
assertNotNull("Engine is not available.", engine);
assertEquals(1234, engine.getPort());
assertEquals("Not http", "http", engine.getProtocol());
Connector connector = engine.getConnector();
Collection<ConnectionFactory> connectionFactories = connector.getConnectionFactories();
assertEquals("Has one HttpConnectionFactory", 1, connectionFactories.size());
ConnectionFactory connectionFactory = connectionFactories.iterator().next();
assertTrue(connectionFactory instanceof HttpConnectionFactory);
HttpConfiguration httpConfiguration = ((HttpConnectionFactory) connectionFactory).getHttpConfiguration();
assertEquals("Has one ForwardedRequestCustomizer", 1, httpConfiguration.getCustomizers().size());
assertTrue(httpConfiguration.getCustomizers().iterator().next() instanceof org.eclipse.jetty.server.ForwardedRequestCustomizer);
}
Aggregations