use of org.mortbay.jetty.servlet.ServletHolder 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.ServletHolder 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.ServletHolder in project jackrabbit by apache.
the class Main method prepareWebapp.
private void prepareWebapp(File file, File repository, File tmp) {
webapp.setContextPath("/");
webapp.setWar(file.getPath());
webapp.setExtractWAR(false);
webapp.setTempDirectory(tmp);
ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class);
servlet.setInitOrder(1);
servlet.setInitParameter("repository.home", repository.getPath());
String conf = command.getOptionValue("conf");
if (conf != null) {
servlet.setInitParameter("repository.config", conf);
}
webapp.addServlet(servlet, "/repository.properties");
}
use of org.mortbay.jetty.servlet.ServletHolder in project jackrabbit by apache.
the class RepositoryStubImpl method getRepository.
@Override
public Repository getRepository() throws RepositoryStubException {
if (repository == null) {
repository = super.getRepository();
}
if (connector == null) {
connector = new SocketConnector();
connector.setHost("localhost");
String pvalue = System.getProperty("org.apache.jackrabbit.jcr2dav.RepositoryStubImpl.port", "0");
int port = pvalue.equals("") ? 0 : Integer.parseInt(pvalue);
connector.setPort(port);
}
if (server == null) {
server = new Server();
server.addConnector(connector);
ServletHolder holder = new ServletHolder(new JcrRemotingServlet() {
protected Repository getRepository() {
return repository;
}
});
holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_RESOURCE_PATH_PREFIX, "");
holder.setInitParameter(JCRWebdavServerServlet.INIT_PARAM_MISSING_AUTH_MAPPING, "");
holder.setInitParameter(JcrRemotingServlet.INIT_PARAM_PROTECTED_HANDLERS_CONFIG, protectedRemoveImplClass);
Context context = new Context(server, "/");
context.addServlet(holder, "/*");
server.addHandler(context);
try {
server.start();
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
if (client == null) {
try {
Map<String, String> parameters = new HashMap<String, String>();
String uri = "http://localhost:" + connector.getLocalPort() + "/";
String parmName = System.getProperty(this.getClass().getName() + ".REPURIPARM", JcrUtils.REPOSITORY_URI);
parameters.put(parmName, uri);
parameters.put(PROP_ACCESSCONTROL_PROVIDER_CLASS, acProviderImplClass);
client = JcrUtils.getRepository(parameters);
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
return client;
}
use of org.mortbay.jetty.servlet.ServletHolder in project nutch by apache.
the class TestProtocolHttp method setUp.
public void setUp(boolean redirection) throws Exception {
conf = new Configuration();
conf.addResource("nutch-default.xml");
conf.addResource("nutch-site-test.xml");
http = new Http();
http.setConf(conf);
server = new Server();
if (redirection) {
root = new Context(server, "/redirection", Context.SESSIONS);
root.setAttribute("newContextURL", "/redirect");
} else {
root = new Context(server, "/", Context.SESSIONS);
}
ServletHolder sh = new ServletHolder(org.apache.jasper.servlet.JspServlet.class);
root.addServlet(sh, "*.jsp");
root.setResourceBase(RES_DIR);
}
Aggregations