use of org.mortbay.jetty.Server in project nutch by apache.
the class CrawlDBTestUtil method getServer.
/**
* Creates a new JettyServer with one static root context
*
* @param port
* port to listen to
* @param staticContent
* folder where static content lives
* @throws UnknownHostException
*/
public static Server getServer(int port, String staticContent) throws UnknownHostException {
Server webServer = new org.mortbay.jetty.Server();
SocketConnector listener = new SocketConnector();
listener.setPort(port);
listener.setHost("127.0.0.1");
webServer.addConnector(listener);
ContextHandler staticContext = new ContextHandler();
staticContext.setContextPath("/");
staticContext.setResourceBase(staticContent);
staticContext.addHandler(new ResourceHandler());
webServer.addHandler(staticContext);
return webServer;
}
use of org.mortbay.jetty.Server in project ghostdriver by detro.
the class CallbackHttpServer method start.
public void start() throws Exception {
server = new Server(0);
Context context = new Context(server, "/");
addServlets(context);
server.start();
}
use of org.mortbay.jetty.Server in project gradle by gradle.
the class JettyRun method finishConfigurationBeforeStart.
public void finishConfigurationBeforeStart() throws Exception {
Handler[] handlers = getConfiguredContextHandlers();
org.gradle.api.plugins.jetty.internal.JettyPluginServer plugin = getServer();
Server server = (Server) plugin.getProxiedObject();
HandlerCollection contexts = (HandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class);
if (contexts == null) {
contexts = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class);
}
for (int i = 0; (handlers != null) && (i < handlers.length); i++) {
contexts.addHandler(handlers[i]);
}
}
use of org.mortbay.jetty.Server in project ambrose by twitter.
the class ScriptStatusServer method run.
/**
* Run the server in the current thread.
*/
@Override
public void run() {
// override newServerSocket to log local port once bound
Connector connector = new SocketConnector() {
@Override
protected ServerSocket newServerSocket(String host, int port, int backlog) throws IOException {
ServerSocket ss = super.newServerSocket(host, port, backlog);
int localPort = ss.getLocalPort();
LOG.info("Ambrose web server listening on port {}", localPort);
LOG.info("Browse to http://localhost:{}/ to see job progress", localPort);
return ss;
}
};
connector.setPort(port);
server = new Server();
server.setConnectors(new Connector[] { connector });
// this needs to be loaded via the jar'ed resources, not the relative dir
String resourcePath = "com/twitter/ambrose/server/web";
URL resourceUrl = checkNotNull(APIHandler.class.getClassLoader().getResource(resourcePath), "Failed to find resource '%s'", resourcePath);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setWelcomeFiles(new String[] { "workflow.html" });
resourceHandler.setResourceBase(resourceUrl.toExternalForm());
HandlerList handler = new HandlerList();
handler.setHandlers(new Handler[] { resourceHandler, new APIHandler(workflowIndexReadService, statsReadService), new DefaultHandler() });
server.setHandler(handler);
server.setStopAtShutdown(false);
try {
server.start();
server.join();
} catch (Exception e) {
LOG.error("Error launching ScriptStatusServer", e);
}
}
use of org.mortbay.jetty.Server in project eureka by Netflix.
the class MockRemoteEurekaServer method start.
public void start() throws Exception {
server = new Server(port);
server.setHandler(new AppsResourceHandler());
server.start();
port = server.getConnectors()[0].getLocalPort();
}
Aggregations