use of org.eclipse.jetty.server.Connector in project athenz by yahoo.
the class AthenzJettyContainerTest method initContainerOnlyHTTPSPort.
@Test
public void initContainerOnlyHTTPSPort() {
System.setProperty(AthenzConsts.ATHENZ_PROP_HOME, "/tmp/ATHENZ_server");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "0");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
System.setProperty("yahoo.zms.debug.user_authority", "true");
AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
assertNotNull(container);
Server server = container.getServer();
Connector[] connectors = server.getConnectors();
assertEquals(connectors.length, 1);
assertTrue(connectors[0].getProtocols().contains("http/1.1"));
assertTrue(connectors[0].getProtocols().contains("ssl"));
}
use of org.eclipse.jetty.server.Connector in project athenz by yahoo.
the class AthenzJettyContainerTest method initContainerInvalidHTTPPort.
@Test
public void initContainerInvalidHTTPPort() {
System.setProperty(AthenzConsts.ATHENZ_PROP_HOME, "/tmp/ATHENZ_server");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "-10");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
assertNotNull(container);
Server server = container.getServer();
Connector[] connectors = server.getConnectors();
assertEquals(connectors.length, 2);
assertTrue(connectors[0].getProtocols().contains("http/1.1"));
assertTrue(connectors[1].getProtocols().contains("http/1.1"));
assertTrue(connectors[1].getProtocols().contains("ssl"));
}
use of org.eclipse.jetty.server.Connector in project athenz by yahoo.
the class AthenzJettyContainerTest method initContainerValidPorts.
@Test
public void initContainerValidPorts() {
System.setProperty(AthenzConsts.ATHENZ_PROP_HOME, "/tmp/ATHENZ_server");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTP_PORT, "4080");
System.setProperty(AthenzConsts.ATHENZ_PROP_HTTPS_PORT, "4443");
AthenzJettyContainer container = AthenzJettyContainer.createJettyContainer();
assertNotNull(container);
Server server = container.getServer();
Connector[] connectors = server.getConnectors();
assertEquals(connectors.length, 2);
assertTrue(connectors[0].getProtocols().contains("http/1.1"));
assertTrue(connectors[1].getProtocols().contains("http/1.1"));
assertTrue(connectors[1].getProtocols().contains("ssl"));
}
use of org.eclipse.jetty.server.Connector in project camel by apache.
the class JettyHttpComponent method connect.
/**
* Connects the URL specified on the endpoint to the specified processor.
*/
@Override
public void connect(HttpConsumer consumer) throws Exception {
// Make sure that there is a connector for the requested endpoint.
JettyHttpEndpoint endpoint = (JettyHttpEndpoint) consumer.getEndpoint();
String connectorKey = getConnectorKey(endpoint);
synchronized (CONNECTORS) {
ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
if (connectorRef == null) {
Server server = createServer();
Connector connector = getConnector(server, endpoint);
if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
LOG.warn("You use localhost interface! It means that no external connections will be available." + " Don't you want to use 0.0.0.0 instead (all network interfaces)? " + endpoint);
}
if (endpoint.isEnableJmx()) {
enableJmx(server);
}
server.addConnector(connector);
connectorRef = new ConnectorRef(server, connector, createServletForConnector(server, connector, endpoint.getHandlers(), endpoint));
// must enable session before we start
if (endpoint.isSessionSupport()) {
enableSessionSupport(connectorRef.server, connectorKey);
}
connectorRef.server.start();
CONNECTORS.put(connectorKey, connectorRef);
} else {
if (endpoint.getHandlers() != null && !endpoint.getHandlers().isEmpty()) {
// As the server is started, we need to stop the server for a while to add the new handler
connectorRef.server.stop();
addJettyHandlers(connectorRef.server, endpoint.getHandlers());
connectorRef.server.start();
}
// ref track the connector
connectorRef.increment();
}
// check the session support
if (endpoint.isSessionSupport()) {
enableSessionSupport(connectorRef.server, connectorKey);
}
if (endpoint.isEnableMultipartFilter()) {
enableMultipartFilter(endpoint, connectorRef.server, connectorKey);
}
if (endpoint.getFilters() != null && endpoint.getFilters().size() > 0) {
setFilters(endpoint, connectorRef.server, connectorKey);
}
connectorRef.servlet.connect(consumer);
}
}
use of org.eclipse.jetty.server.Connector in project camel by apache.
the class ExplicitHttpsRouteTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws URISyntaxException {
// START SNIPPET: e1
// create SSL select channel connectors for port 9080 and 9090
Map<Integer, Connector> connectors = new HashMap<Integer, Connector>();
connectors.put(port1, createSslSocketConnector(port1));
connectors.put(port2, createSslSocketConnector(port2));
JettyHttpComponent jetty = getContext().getComponent("jetty", JettyHttpComponent.class);
jetty.setSslSocketConnectors(connectors);
// END SNIPPET: e1
from("jetty:https://localhost:" + port1 + "/test").to("mock:a");
Processor proc = new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody("<b>Hello World</b>");
}
};
from("jetty:https://localhost:" + port1 + "/hello").process(proc);
from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
}
};
}
Aggregations