use of org.eclipse.jetty.server.handler.HandlerList in project Universal-G-Code-Sender by winder.
the class PendantUI method start.
/**
* Launches the local web server.
* @return the url for the pendant interface
*/
public List<PendantURLBean> start() {
server = new Server(port);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(false);
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setBaseResource(getBaseResource());
resourceHandler.setDirectoriesListed(true);
ContextHandler sendGcodeContext = new ContextHandler();
sendGcodeContext.setContextPath("/sendGcode");
sendGcodeContext.setBaseResource(getBaseResource());
sendGcodeContext.setClassLoader(Thread.currentThread().getContextClassLoader());
sendGcodeContext.setHandler(new SendGcodeHandler());
ContextHandler adjustManualLocationContext = new ContextHandler();
adjustManualLocationContext.setContextPath("/adjustManualLocation");
adjustManualLocationContext.setBaseResource(getBaseResource());
adjustManualLocationContext.setClassLoader(Thread.currentThread().getContextClassLoader());
adjustManualLocationContext.setHandler(new AdjustManualLocationHandler());
ContextHandler getSystemStateContext = new ContextHandler();
getSystemStateContext.setContextPath("/getSystemState");
getSystemStateContext.setBaseResource(getBaseResource());
getSystemStateContext.setClassLoader(Thread.currentThread().getContextClassLoader());
getSystemStateContext.setHandler(new GetSystemStateHandler());
ContextHandler configContext = new ContextHandler();
configContext.setContextPath("/config");
configContext.setBaseResource(getBaseResource());
configContext.setClassLoader(Thread.currentThread().getContextClassLoader());
configContext.setHandler(new ConfigHandler());
configContext.setInitParameter("cacheControl", "max-age=0, public");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { configContext, sendGcodeContext, adjustManualLocationContext, getSystemStateContext, resourceHandler, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
return getUrlList();
}
use of org.eclipse.jetty.server.handler.HandlerList in project archiva by apache.
the class RemoteRepositoryConnectivityCheckTest method buildStaticServer.
protected Server buildStaticServer(Path path) {
Server repoServer = new Server();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase(path.toAbsolutePath().toString());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler() });
repoServer.setHandler(handlers);
return repoServer;
}
use of org.eclipse.jetty.server.handler.HandlerList in project ddf by codice.
the class JettySessionManagementTest method setupClass.
@BeforeClass
public static void setupClass() throws Exception {
// To get the AccessRequestLog to log in the target folder
System.setProperty("ddf.data", "target");
server = new Server();
HandlerList handlers = new HandlerList();
server.setHandler(handlers);
// Configure server according to the jetty.xml file
XmlConfiguration configuration = new XmlConfiguration(JettySessionManagementTest.class.getResourceAsStream("/jetty-session.xml"));
configuration.configure(server);
// Have server bind to first available port
ServerConnector connector = new ServerConnector(server);
connector.setPort(0);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(null, "/context1", ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new TestServlet()), "/");
context.getSessionHandler().setMaxInactiveInterval(MAX_INACTIVE_INTERVAL_SECONDS);
handlers.addHandler(context);
ServletContextHandler context2 = new ServletContextHandler(null, "/context2", ServletContextHandler.SESSIONS);
context2.addServlet(new ServletHolder(new TestServlet()), "/");
context2.getSessionHandler().setMaxInactiveInterval(MAX_INACTIVE_INTERVAL_SECONDS);
handlers.addHandler(context2);
HouseKeeper houseKeeper = new HouseKeeper();
houseKeeper.setIntervalSec(SCAVENGE_INTERVAL_SECONDS);
server.getSessionIdManager().setSessionHouseKeeper(houseKeeper);
server.start();
port = connector.getLocalPort();
}
use of org.eclipse.jetty.server.handler.HandlerList in project leopard by tanhaichao.
the class WebappDaoImpl method getHandlerList.
protected Handler getHandlerList(List<String> hostList) {
// jettyServer.getWebappService().addHandler(new HostResourceHandler("ftrade.leopard.io", "/data/src/ftrade_html/"));
if (hostList.contains("fshop.leopard.io")) {
if (false) {
return new HostResourceHandler("fshop.leopard.io", "/data/src/fshop_html/");
}
HandlerList handlerList = new HandlerList();
handlerList.addHandler(new HostResourceHandler("fshop.leopard.io", "/data/src/fshop_html/"));
handlerList.addHandler(new HostResourceHandler("ftrade.leopard.io", "/data/src/ftrade_html/"));
try {
handlerList.start();
} catch (Exception e) {
e.printStackTrace();
}
return handlerList;
}
return null;
}
use of org.eclipse.jetty.server.handler.HandlerList in project scheduling by ow2-proactive.
the class JettyStarter method printDeployedApplications.
private List<String> printDeployedApplications(Server server, String schedulerHost, int restPort, String httpProtocol) {
HandlerList handlerList = null;
if (WebProperties.WEB_PCA_PROXY_REWRITE_ENABLED.getValueAsBoolean()) {
HandlerList topLevelHandlerList = (HandlerList) server.getHandler();
for (Handler handler : topLevelHandlerList.getHandlers()) {
if (handler instanceof RewriteHandler) {
handlerList = (HandlerList) ((RewriteHandler) handler).getHandler();
}
}
} else {
handlerList = (HandlerList) server.getHandler();
}
ArrayList<String> applicationsUrls = new ArrayList<>();
if (handlerList.getHandlers() != null) {
for (Handler handler : handlerList.getHandlers()) {
if (!(handler instanceof WebAppContext)) {
continue;
}
WebAppContext webAppContext = (WebAppContext) handler;
Throwable startException = webAppContext.getUnavailableException();
if (startException == null) {
if (!"/".equals(webAppContext.getContextPath())) {
String applicationUrl = getApplicationUrl(httpProtocol, schedulerHost, restPort, webAppContext);
applicationsUrls.add(applicationUrl);
logger.info("The web application " + webAppContext.getContextPath() + " created on " + applicationUrl);
}
} else {
logger.warn("Failed to start context " + webAppContext.getContextPath(), startException);
}
}
logger.info("*** Get started at " + httpProtocol + "://" + schedulerHost + ":" + restPort + " ***");
}
return applicationsUrls;
}
Aggregations