use of org.mortbay.jetty.servlet.Context in project voldemort by voldemort.
the class HttpService method startInner.
@Override
public void startInner() {
try {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setLowResourceMaxIdleTime(3000);
connector.setPort(this.port);
connector.setReuseAddress(true);
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("VoldemortHttp");
threadPool.setMaxThreads(this.numberOfThreads);
Server httpServer = new Server();
httpServer.setConnectors(new Connector[] { connector });
httpServer.setThreadPool(threadPool);
httpServer.setSendServerVersion(false);
httpServer.setSendDateHeader(false);
Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY, velocityEngine);
context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)), "/admin");
context.addServlet(new ServletHolder(new StoreServlet(requestHandler)), "/stores");
context.addServlet(new ServletHolder(new ReadOnlyStoreManagementServlet(server, velocityEngine)), "/read-only/mgmt");
context.addServlet(new ServletHolder(new StatusServlet(server, velocityEngine)), "/server-status");
this.context = context;
this.httpServer = httpServer;
this.httpServer.start();
logger.info("HTTP service started on port " + this.port);
} catch (Exception e) {
String errorMessage = " Error starting service on port " + this.port;
throw new VoldemortException(errorMessage, e);
}
}
use of org.mortbay.jetty.servlet.Context in project voldemort by voldemort.
the class ServerTestUtils method getJettyServer.
public static Context getJettyServer(String clusterXml, String storesXml, String storeName, RequestFormatType requestFormat, int port) throws Exception {
StoreRepository repository = getStores(storeName, clusterXml, storesXml);
// initialize servlet
Server server = new Server(port);
server.setSendServerVersion(false);
Context context = new Context(server, "/", Context.NO_SESSIONS);
RequestHandler handler = getSocketRequestHandlerFactory(clusterXml, storesXml, repository).getRequestHandler(requestFormat);
context.addServlet(new ServletHolder(new StoreServlet(handler)), "/stores");
server.start();
return context;
}
use of org.mortbay.jetty.servlet.Context 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.servlet.Context in project jackrabbit by apache.
the class LitmusTest method testLitmus.
public void testLitmus() throws Exception {
File dir = new File("target", "litmus");
String litmus = System.getProperty("litmus", "litmus");
if (Boolean.getBoolean("jackrabbit.test.integration") && isLitmusAvailable(litmus)) {
final Repository repository = JcrUtils.getRepository("jcr-jackrabbit://" + Text.escapePath(dir.getCanonicalPath()));
// for the TransientRepository
Session session = repository.login();
try {
SocketConnector connector = new SocketConnector();
connector.setHost("localhost");
connector.setPort(Integer.getInteger("litmus.port", 0));
Server server = new Server();
server.addConnector(connector);
ServletHolder holder = new ServletHolder(new SimpleWebdavServlet() {
@Override
public Repository getRepository() {
return repository;
}
});
holder.setInitParameter("resource-config", "/config.xml");
Context context = new Context(server, "/");
context.setResourceBase("src/test/resources");
context.addServlet(holder, "/*");
server.addHandler(context);
server.start();
try {
int port = connector.getLocalPort();
String url = "http://localhost:" + port + "/default";
ProcessBuilder builder = new ProcessBuilder(litmus, url, "admin", "admin");
builder.directory(dir);
builder.redirectErrorStream();
assertLitmus(builder, "basic", 0);
assertLitmus(builder, "http", 0);
assertLitmus(builder, "props", 0);
// FIXME: JCR-2637: WebDAV shallow copy test failure
assertLitmus(builder, "copymove", 1);
// FIXME: JCR-2638: Litmus locks test failures
assertLitmus(builder, "locks", 1);
} finally {
server.stop();
}
} finally {
session.logout();
}
}
}
Aggregations