use of org.eclipse.jetty.server.Server in project camel by apache.
the class CMISTestSupport method startServer.
@BeforeClass
public static void startServer() throws Exception {
port = AvailablePortFinder.getNextAvailable(26500);
cmisServer = new Server(port);
cmisServer.setHandler(new WebAppContext(OPEN_CMIS_SERVER_WAR_PATH, "/chemistry-opencmis-server-inmemory"));
cmisServer.start();
}
use of org.eclipse.jetty.server.Server in project camel by apache.
the class CometdComponent method createServer.
protected Server createServer() throws Exception {
Server server = new Server();
ContextHandlerCollection collection = new ContextHandlerCollection();
server.setHandler(collection);
return server;
}
use of org.eclipse.jetty.server.Server in project camel by apache.
the class CometdComponent method connect.
/**
* Connects the URL specified on the endpoint to the specified processor.
*/
public void connect(CometdProducerConsumer prodcon) throws Exception {
Server server = null;
// Make sure that there is a connector for the requested endpoint.
CometdEndpoint endpoint = prodcon.getEndpoint();
String connectorKey = endpoint.getProtocol() + ":" + endpoint.getUri().getHost() + ":" + endpoint.getPort();
synchronized (connectors) {
ConnectorRef connectorRef = connectors.get(connectorKey);
if (connectorRef == null) {
ServerConnector connector;
server = createServer();
if ("cometds".equals(endpoint.getProtocol())) {
connector = getSslSocketConnector(server);
} else {
connector = new ServerConnector(server);
}
connector.setPort(endpoint.getPort());
connector.setHost(endpoint.getUri().getHost());
if ("localhost".equalsIgnoreCase(endpoint.getUri().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)?");
}
server.addConnector(connector);
CometDServlet servlet = createServletForConnector(server, connector, endpoint);
connectorRef = new ConnectorRef(connector, servlet, server);
server.start();
connectors.put(connectorKey, connectorRef);
} else {
connectorRef.increment();
}
BayeuxServerImpl bayeux = connectorRef.servlet.getBayeux();
if (securityPolicy != null) {
bayeux.setSecurityPolicy(securityPolicy);
}
if (extensions != null) {
for (BayeuxServer.Extension extension : extensions) {
bayeux.addExtension(extension);
}
}
if (serverListeners != null) {
for (BayeuxServer.BayeuxServerListener serverListener : serverListeners) {
bayeux.addListener(serverListener);
}
}
prodcon.setBayeux(bayeux);
}
}
use of org.eclipse.jetty.server.Server in project camel by apache.
the class CometdCrossOriginConsumerTest method testCrossOriginFilterNotAddedWhenOff.
@Test
public void testCrossOriginFilterNotAddedWhenOff() throws Exception {
// setup
CometdComponent component = context.getComponent("cometd", CometdComponent.class);
Server server = new Server();
when(endpoint.isCrossOriginFilterOn()).thenReturn(false);
// act
component.createServletForConnector(server, connector, endpoint);
// assert
ServletContextHandler handler = (ServletContextHandler) server.getHandler();
assertEquals(0, handler.getServletHandler().getFilters().length);
}
use of org.eclipse.jetty.server.Server in project camel by apache.
the class CometdCrossOriginConsumerTest method testCrossOriginFilterAddedWhenOn.
@Test
public void testCrossOriginFilterAddedWhenOn() throws Exception {
// setup
CometdComponent component = context.getComponent("cometd", CometdComponent.class);
Server server = new Server();
when(endpoint.isCrossOriginFilterOn()).thenReturn(true);
when(endpoint.getFilterPath()).thenReturn(FILTER_PATH);
when(endpoint.getAllowedOrigins()).thenReturn(ALLOWED_ORIGINS);
// act
component.createServletForConnector(server, connector, endpoint);
// assert
ServletContextHandler handler = (ServletContextHandler) server.getHandler();
assertEquals(1, handler.getServletHandler().getFilters().length);
FilterHolder filterHolder = handler.getServletHandler().getFilters()[0];
Filter filter = filterHolder.getFilter();
assertTrue(filter instanceof CrossOriginFilter);
}
Aggregations