org.mortbay.jetty.handler.HandlerList Java Examples
The following examples show how to use
org.mortbay.jetty.handler.HandlerList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Main.java From blog-codes with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { Server server = new Server(PORT); // Static file handler Context fileContext = new Context(server, "/mxgraph", Context.SESSIONS); ResourceHandler fileHandler = new ResourceHandler(); fileHandler.setResourceBase("."); fileContext.setHandler(fileHandler); // Servlets Context context = new Context(server, "/", Context.SESSIONS); context.addServlet(new ServletHolder(new Roundtrip()), "/Roundtrip"); context.addServlet(new ServletHolder(new ServerView()), "/ServerView"); context.addServlet(new ServletHolder(new ExportServlet()), "/Export"); context.addServlet(new ServletHolder(new EchoServlet()), "/Echo"); context.addServlet(new ServletHolder(new Deploy()), "/Deploy"); context.addServlet(new ServletHolder(new Link()), "/Link"); context.addServlet(new ServletHolder(new EmbedImage()), "/EmbedImage"); context.addServlet(new ServletHolder(new Backend()), "/Backend"); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { new RedirectHandler(), fileContext, context, new DefaultHandler() }); server.setHandler(handlers); System.out.println("Go to http://localhost:" + PORT + "/"); server.start(); server.join(); }
Example #2
Source File: ErrorConditionsTest.java From reladomo with Apache License 2.0 | 5 votes |
public void setErrorCausingHandler(int causeErrorOnEventNumber) throws Exception { HttpErrorCausingHandler handler = new HttpErrorCausingHandler(causeErrorOnEventNumber); HandlerList list = new HandlerList(); list.addHandler(handler); this.setupServerWithHandler(list); }
Example #3
Source File: AbstractServerMojo.java From opoopress with Apache License 2.0 | 5 votes |
protected Server createJettyServer(Site site){ Server server = new Server(); //FIXME server.setStopAtShutdown(true); Connector defaultConnector = createConnector(null, port); server.setConnectors( new Connector[] { defaultConnector } ); String root = site.getRoot(); String resourceBase = site.getDestination().getPath(); getLog().info("Server resource base: " + resourceBase); if("".equals(root)){ ResourceHandler resourceHandler = new ResourceHandler(); //resourceHandler.setDirectoriesListed(true); resourceHandler.setWelcomeFiles(new String[]{"index.html"}); resourceHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler()}); server.setHandler(handlers); //server.setHandlers(new Handler[]{handlers, logHandler}); //getLog().info( "Startisng preview server on http://localhost:" + port + "/" ); } else { getLog().info("Using " + ContextHandler.class.getName()); ContextHandler contextHandler = new ContextHandler(); contextHandler.setContextPath(root); contextHandler.setHandler(new ResourceHandler()); contextHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/); //server.setHandler(contextHandler); server.setHandlers(new Handler[]{contextHandler, new DefaultHandler()}); //server.setHandlers(new Handler[]{contextHandler, logHandler}); //log.info( "Starting preview server on http://localhost:" + port + root ); } return server; }