use of org.eclipse.jetty.server.Connector in project camel by apache.
the class WsProducerConsumerTest method startTestServer.
public void startTestServer() throws Exception {
// start a simple websocket echo service
server = new Server(PORT);
Connector connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler ctx = new ServletContextHandler();
ctx.setContextPath("/");
ctx.addServlet(TestServletFactory.class.getName(), "/*");
server.setHandler(ctx);
server.start();
assertTrue(server.isStarted());
}
use of org.eclipse.jetty.server.Connector in project symmetric-ds by JumpMind.
the class SymmetricWebServer method getConnectors.
protected Connector[] getConnectors(Server server, int port, int securePort, Mode mode) {
ArrayList<Connector> connectors = new ArrayList<Connector>();
HttpConfiguration httpConfig = new HttpConfiguration();
if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(securePort);
}
httpConfig.setOutputBufferSize(32768);
if (mode.equals(Mode.HTTP) || mode.equals(Mode.MIXED)) {
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(port);
http.setHost(host);
http.setIdleTimeout(maxIdleTime);
connectors.add(http);
log.info(String.format("About to start %s web server on host:port %s:%s", name, host == null ? "default" : host, port));
}
if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
ISecurityService securityService = SecurityServiceFactory.create(SecurityServiceType.SERVER, new TypedProperties(System.getProperties()));
securityService.installDefaultSslCert(host);
String keyStorePassword = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD);
keyStorePassword = (keyStorePassword != null) ? keyStorePassword : SecurityConstants.KEYSTORE_PASSWORD;
SslContextFactory sslConnectorFactory = new SslContextFactory();
sslConnectorFactory.setKeyManagerPassword(keyStorePassword);
/* Prevent POODLE attack */
String ignoredProtocols = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_PROTOCOLS);
if (ignoredProtocols != null && ignoredProtocols.length() > 0) {
String[] protocols = ignoredProtocols.split(",");
sslConnectorFactory.addExcludeProtocols(protocols);
} else {
sslConnectorFactory.addExcludeProtocols("SSLv3");
}
String ignoredCiphers = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_CIPHERS);
if (ignoredCiphers != null && ignoredCiphers.length() > 0) {
String[] ciphers = ignoredCiphers.split(",");
sslConnectorFactory.addExcludeCipherSuites(ciphers);
}
sslConnectorFactory.setCertAlias(System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_CERT_ALIAS, SecurityConstants.ALIAS_SYM_PRIVATE_KEY));
sslConnectorFactory.setKeyStore(securityService.getKeyStore());
sslConnectorFactory.setTrustStore(securityService.getTrustStore());
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslConnectorFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
https.setPort(securePort);
https.setIdleTimeout(maxIdleTime);
https.setHost(host);
connectors.add(https);
log.info(String.format("About to start %s web server on secure host:port %s:%s", name, host == null ? "default" : host, securePort));
}
return connectors.toArray(new Connector[connectors.size()]);
}
use of org.eclipse.jetty.server.Connector in project jena by apache.
the class SPARQLServer method defaultServerConfig.
private static Server defaultServerConfig(int port, boolean loopback) {
// Server, with one NIO-based connector, large input buffer size (for
// long URLs, POSTed forms (queries, updates)).
Server server = new Server();
// Using "= new SelectChannelConnector() ;" on Darwin (OS/X) causes
// problems
// with initialization not seen (thread scheduling?) in Joseki.
// BlockingChannelConnector is better for pumping large responses back
// but there have been observed problems with DirectMemory allocation
// (-XX:MaxDirectMemorySize=1G does not help)
// Connector connector = new SelectChannelConnector() ;
// Connector and specific settings.
BlockingChannelConnector bcConnector = new BlockingChannelConnector();
// bcConnector.setUseDirectBuffers(false) ;
Connector connector = bcConnector;
// Ignore. If set, then if this goes off, it keeps going off
// and you get a lot of log messages.
// Jetty outputs a lot of messages if this
connector.setMaxIdleTime(0);
// goes off.
if (loopback)
connector.setHost("localhost");
connector.setPort(port);
// Some people do try very large operations ...
connector.setRequestHeaderSize(64 * 1024);
connector.setRequestBufferSize(5 * 1024 * 1024);
connector.setResponseBufferSize(5 * 1024 * 1024);
server.addConnector(connector);
return server;
}
use of org.eclipse.jetty.server.Connector in project qi4j-sdk by Qi4j.
the class AbstractJettyMixin method stopJetty.
@Override
public final void stopJetty() throws Exception {
server.stop();
for (Connector connector : server.getConnectors()) {
connector.stop();
}
server = null;
}
use of org.eclipse.jetty.server.Connector in project qi4j-sdk by Qi4j.
the class AbstractJettyMixin method interfacesServed.
@Override
@SuppressWarnings("ValueOfIncrementOrDecrementUsed")
public final Interface[] interfacesServed() {
Connector[] connectors = server.getConnectors();
Interface[] result = new Interface[connectors.length];
int index = 0;
for (Connector connector : connectors) {
if (connector instanceof NetworkConnector) {
NetworkConnector netConnector = (NetworkConnector) connector;
String host = configuration().hostName().get();
if (host == null) {
host = netConnector.getHost();
if (// If serving all interfaces.
host == null) {
try {
host = InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
InternalError error = new InternalError("UnknownHost for local interface.");
error.initCause(e);
throw error;
}
}
}
result[index++] = new InterfaceImpl(host, netConnector.getPort(), servedProtocol());
}
}
return result;
}
Aggregations