Package org.mortbay.jetty.handler

Examples of org.mortbay.jetty.handler.HandlerList


                super.handle( target, request, response, dispatch );
//                System.out.println( "  ::  " + ( (Response) response ).getStatus() );
            }
        };
        resource_handler.setResourceBase( fakeCentral.getAbsolutePath() );
        HandlerList handlers = new HandlerList();
        handlers.setHandlers( new Handler[] { resource_handler, new DefaultHandler() } );
        server.setHandler( handlers );

//        System.out.print( "JETTY Started on port: " + port );
        server.start();
View Full Code Here


    @Override
    public void init() {
        super.init();

        final HandlerList handlers = createHandlers();

        final ContextHandler contextHandler = createContextHandler(handlers);

        startServer(contextHandler);
    }
View Full Code Here

        startServer(contextHandler);
    }

    private HandlerList createHandlers() {
        final HandlerList handlers = new HandlerList();

        addResourcesAndWelcomeFiles(handlers);

        final ServletHandler servletHandler = new ServletHandler();
        addServletsAndFilters(servletHandler);

        final SessionHandler sessionHandler = new SessionHandler();
        sessionHandler.setHandler(servletHandler);
        handlers.addHandler(sessionHandler);

        // commenting out; this grabs '/' but we might want to use it ourselves,
        // instead?
        // handlers.addHandler(new DefaultHandler());

        // TODO use properties to set up
        final RequestLogHandler requestLogHandler = new RequestLogHandler();
        handlers.addHandler(requestLogHandler);
        final NCSARequestLog requestLog = new NCSARequestLog("./logs/jetty-yyyy_mm_dd.request.log");
        requestLog.setRetainDays(90);
        requestLog.setAppend(true);
        requestLog.setExtended(false);
        requestLog.setLogTimeZone("GMT");
View Full Code Here

       
        ResourceHandler resource_handler=new ResourceHandler();
        resource_handler.setWelcomeFiles(new String[]{"index.html"});
        resource_handler.setResourceBase(args.length==2?args[1]:".");
        Log.info("serving "+resource_handler.getBaseResource());
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{resource_handler,new DefaultHandler()});
        server.setHandler(handlers);
       
        server.start();
        server.join();
    }
View Full Code Here

    connector.setPort(port);
    connector.setResolveNames(false);
    server.addConnector(connector);
   
    // create a list of handlers
    HandlerList list = new HandlerList();
    server.addHandler(list);
   
    if (debug) {
      LOG.info("* Added debug handler.");
      list.addHandler(new LogDebugHandler());
    }
    if (delay) {
      LOG.info("* Added delay handler: " + (delayVal < 0 ? "random delay up to " + (-delayVal) : "constant delay of " + delayVal));
      list.addHandler(new DelayHandler(delayVal));
    }
   
    // XXX alternatively, we can add the DispatchHandler as the first one,
    // XXX to activate handler plugins and redirect requests to appropriate
    // XXX handlers ... Here we always load these handlers

    Iterator<Path> it = segs.iterator();
    while (it.hasNext()) {
      Path p = it.next();
      try {
        SegmentHandler segment = new SegmentHandler(conf, p);
        list.addHandler(segment);
        LOG.info("* Added segment handler for: " + p);
      } catch (Exception e) {
        LOG.warn("Skipping segment '" + p + "': " + StringUtils.stringifyException(e));
      }
    }
    if (forward) {
      LOG.info("* Adding forwarding proxy for all unknown urls ...");
      ServletHandler servlets = new ServletHandler();
      servlets.addServletWithMapping(AsyncProxyServlet.class, "/*");
      servlets.addFilterWithMapping(LogDebugHandler.class, "/*", Handler.ALL);
      list.addHandler(servlets);
    }
    if (fake) {
      LOG.info("* Added fake handler for remaining URLs.");
      list.addHandler(new FakeHandler());
    }
    list.addHandler(new NotFoundHandler());
    // Start the http server
    server.start();
    server.join();
  }
View Full Code Here

                    LOG.finer("connector.port: " + connector.getPort());
                }
            }
            server.addConnector(connector);           
            if (handlers != null && handlers.size() > 0) {
                HandlerList handlerList = new HandlerList();
                for (Handler h : handlers) {
                    // filting the jetty default handler
                    // which should not be added at this point
                    if (h instanceof DefaultHandler) {
                        defaultHandler = (DefaultHandler) h;
                    } else {
                        handlerList.addHandler(h);
                    }
                }
                server.addHandler(handlerList);
            }
            contexts = new ContextHandlerCollection();
View Full Code Here

                    LOG.finer("connector.port: " + connector.getPort());
                }
            }
            server.addConnector(connector);           
            if (handlers != null && handlers.size() > 0) {
                HandlerList handlerList = new HandlerList();
                for (Handler h : handlers) {
                    // filting the jetty default handler
                    // which should not be added at this point
                    if (h instanceof DefaultHandler) {
                        defaultHandler = (DefaultHandler) h;
                    } else {
                        handlerList.addHandler(h);
                    }
                }
                server.addHandler(handlerList);
            }
            contexts = new ContextHandlerCollection();
View Full Code Here

        // run the web server
        Server server = new Server(8089);
        ResourceHandler resource_handler = new myResourceHandler();
        resource_handler.setResourceBase(tmpDir+"/testweb");
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[] {resource_handler, new DefaultHandler()});
        server.setHandler(handlers);
        server.start();

        // prepare the crawler
        TestUtils.writeFile(tmpDir+"/testhotspot", "*");
 
View Full Code Here

    server = new Server( 8082 );
    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setResourceBase( ".\\src\\test-resources" );

    HandlerList handlers = new HandlerList();
    handlers.setHandlers( new Handler[] { resource_handler, new DefaultHandler() } );
    server.setHandler( handlers );

    try
    {
      server.start();
View Full Code Here

      // Hook for subclass to add more servlets
      if (contextCallback != null) {
        contextCallback.configureContext(servlets);
      }

      final HandlerList handlers = new HandlerList();
      handlers.setHandlers(new Handler[]{
          cajaStatic,
          servlets,
          new DefaultHandler()});
      caja.setHandler(handlers);
    }

    final HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
        resource_handler,
        caja,
        new DefaultHandler()});
    server.setHandler(handlers);
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.handler.HandlerList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.