Server server = new Server(8080); WebSocketHandler wsHandler = new WebSocketHandler() { @Override public void configure(WebSocketServletFactory factory) { factory.register(MyEchoSocket.class); } }; ContextHandler context = new ContextHandler(); context.setContextPath("/echo"); context.setHandler(wsHandler); server.addHandler(context); server.start(); server.join();
sch.setContextPath("/"); sch.setHandler(new JettyHandler(handler, webSocketServerFactory, conf .getString("application.tmpdir"), conf.getBytes("jetty.FileSizeThreshold").intValue()));
@Override public void start() { writeTimeToFile("startingAt"); ContextHandler context = new ContextHandler(); context.setContextPath("/"); context.setClassLoader(Thread.currentThread().getContextClassLoader()); server.setHandler(context); context.setHandler(new AbstractHandler() { @Override public void handle(String target, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException { if ("/ping".equals(target)) { request.setHandled(true); httpServletResponse.getWriter().print("ping"); } else if ("/restart".equals(target)) { writeTimeToFile("restartAskedAt"); request.setHandled(true); processCommands.askForRestart(); httpServletResponse.getWriter().print("ok"); } else if ("/kill".equals(target)) { writeTimeToFile("killedAt"); System.exit(0); } } }); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Fail to start Jetty", e); } }
sendGcodeContext.setContextPath("/sendGcode"); sendGcodeContext.setBaseResource(getBaseResource()); sendGcodeContext.setClassLoader(Thread.currentThread().getContextClassLoader()); adjustManualLocationContext.setContextPath("/adjustManualLocation"); adjustManualLocationContext.setBaseResource(getBaseResource()); adjustManualLocationContext.setClassLoader(Thread.currentThread().getContextClassLoader()); getSystemStateContext.setContextPath("/getSystemState"); getSystemStateContext.setBaseResource(getBaseResource()); getSystemStateContext.setClassLoader(Thread.currentThread().getContextClassLoader()); configContext.setContextPath("/config"); configContext.setBaseResource(getBaseResource()); configContext.setClassLoader(Thread.currentThread().getContextClassLoader());
/** * */ public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
/** * */ public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
/** * */ public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
/** * */ public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
/** * */ public ContextHandler(String contextPath) { this(); setContextPath(contextPath); }
/** * */ public ContextHandler(HandlerContainer parent, String contextPath) { this(); setContextPath(contextPath); if (parent instanceof HandlerWrapper) ((HandlerWrapper)parent).setHandler(this); else if (parent instanceof HandlerCollection) ((HandlerCollection)parent).addHandler(this); }
/** * */ public ContextHandler(HandlerContainer parent, String contextPath) { this(); setContextPath(contextPath); if (parent instanceof HandlerWrapper) ((HandlerWrapper)parent).setHandler(this); else if (parent instanceof HandlerCollection) ((HandlerCollection)parent).addHandler(this); }
/** * */ public ContextHandler(HandlerContainer parent, String contextPath) { this(); setContextPath(contextPath); if (parent instanceof HandlerWrapper) ((HandlerWrapper)parent).setHandler(this); else if (parent instanceof HandlerCollection) ((HandlerCollection)parent).addHandler(this); }
/** * */ public ContextHandler(HandlerContainer parent, String contextPath) { this(); setContextPath(contextPath); if (parent instanceof HandlerWrapper) ((HandlerWrapper)parent).setHandler(this); else if (parent instanceof HandlerCollection) ((HandlerCollection)parent).addHandler(this); }
ServerConnector httpConnector = new ServerConnector(server); httpConnector.setName("unsecured"); // named connector httpConnector.setPort(80); ContextHandler helloHandler = new ContextHandler(); helloHandler.setContextPath("/hello"); helloHandler.setHandler(new HelloHandler("Hello World")); helloHandler.setVirtualHosts(new String[]{"@unsecured"});
ResourceHandler staticResource = new ResourceHandler(); staticResource.setDirectoriesListed(true); staticResource.setWelcomeFiles(new String[] { "index.html" }); staticResource.setResourceBase("/path/to/your/files"); ContextHandler staticContextHandler = new ContextHandler(); staticContextHandler.setContextPath("/*"); staticContextHandler.setHandler(staticResource); Server server = new Server(8080); server.setHandler(staticContextHandler);
ContextHandler capHandler = new ContextHandler(); capHandler.setContextPath("/clientaccesspolicy.xml"); ResourceHandler resHandler = new ResourceHandler(); resHandler.setBaseResource(Resource.newClassPathResource("clientaccesspolicy.xml")); capHandler.setHandler(resHandler);
public void addStaticResources(String basePath, String resourcePath) { ContextHandler capHandler = new ContextHandler(); capHandler.setContextPath(basePath); ResourceHandler resHandler = new ResourceHandler(); resHandler.setBaseResource(Resource.newClassPathResource(resourcePath)); resHandler.setEtags(true); resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL); capHandler.setHandler(resHandler); handlers.add(capHandler); }
public void addStaticResources(String basePath, String resourcePath) { ContextHandler capHandler = new ContextHandler(); capHandler.setContextPath(basePath); ResourceHandler resHandler = new ResourceHandler(); resHandler.setBaseResource(Resource.newClassPathResource(resourcePath)); resHandler.setEtags(true); resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL); capHandler.setHandler(resHandler); handlers.add(capHandler); }
public void addResourceContext(String context, File directory) throws MalformedURLException, IOException { ContextHandler contextHandler = new ContextHandler(); ResourceHandler contentResourceHandler = new ResourceHandler(); contextHandler.setBaseResource(Resource.newResource(directory)); contextHandler.setHandler(contentResourceHandler); contextHandler.setContextPath(context); addContextHandler(contextHandler); }