Examples of ContextHandler


Examples of org.eclipse.jetty.server.handler.ContextHandler

  private ContextHandler createUpdateContext() {
    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    File rootFolder = new RootFolderSelector().getRootFolder();
    resource_handler.setResourceBase(new File(rootFolder, "src/test/resources/httpUpdateServerBase").getAbsolutePath());
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setHandler(resource_handler);
    contextHandler.setContextPath("/updates");
    return contextHandler;
  }
View Full Code Here

Examples of org.eclipse.jetty.server.handler.ContextHandler

    contextHandler.setContextPath("/updates");
    return contextHandler;
  }

  private ContextHandler createRootContext() {
    ContextHandler rootContext = new ContextHandler("/");
    rootContext.setHandler(new DefaultHandler());
    return rootContext;
  }
View Full Code Here

Examples of org.eclipse.jetty.server.handler.ContextHandler

      return gzipHandler;
   }

   private ContextHandler constructHandler(final String connectorName, final String pathInfo, final Handler handler) {

      final ContextHandler contextHandler = new ContextHandler();
      contextHandler.setContextPath(pathInfo);
      contextHandler.setAllowNullPathInfo(true);
      contextHandler.setConnectorNames(new String[]{connectorName});
      contextHandler.addLocaleEncoding(Locale.US.getDisplayName(), StringUtils.UTF_8);
      contextHandler.setHandler(handler);

      final MimeTypes mimeTypes = new MimeTypes();
      mimeTypes.setMimeMap(new HashMap());
      contextHandler.setMimeTypes(mimeTypes);

      return contextHandler;
   }
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

    SocketConnector connector = new SocketConnector();
    connector.setPort( port );
    server.addConnector( connector );

    // Create a context
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath( "" );
    server.addHandler( contextHandler );

    // Create a servlet container
    ServletHandler servlets = new ServletHandler();
    contextHandler.addHandler( servlets );

    contextHandler.setAttribute( "queryEngine", queryEngine );
    contextHandler.setAttribute( "collection", collection );
    contextHandler.setAttribute( "titleList", titleList );
    contextHandler.setAttribute( "action", "/Query" );
    // TODO: very rudimentary: we should get the template from somewhere else instead...
    contextHandler.setAttribute( "template", System.getProperty( "it.unimi.dsi.mg4j.query.QueryServlet.template" ) );

    // Maps the main servlet onto the container.
    servlets.addServletWithMapping( QueryServlet.class, "/Query" );
    servlets.addServletWithMapping( HelpPage.class, "/Help" );
   
    /* If an item servlet was specified, we link it to /Item. Otherwise,
     * we inform the query servlet that it should generate direct URIs. */

    if ( itemClass != null ) {
      servlets.addServletWithMapping( itemClass, "/Item" );
      if ( itemClass == FileSystemItem.class ) contextHandler.setAttribute( "derelativise", Boolean.TRUE );
    }
    else contextHandler.setAttribute( "uri", Boolean.TRUE );

    contextHandler.setAttribute( "mimeType", itemMimeType );

    // Start the http server
    server.start();
  }
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

    public static ContextHandler getCurrentWebAppContext()
    {
        ContextHandler.SContext context=ContextHandler.getCurrentContext();
        if (context!=null)
        {
            ContextHandler handler = context.getContextHandler();
            if (handler instanceof WebAppContext)
                return (ContextHandler)handler;
        }
        return null;  
    }
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

            for ( Handler h : handlers )
            {
                if ( h instanceof ContextHandler )
                {
                    ContextHandler ch = ( ContextHandler ) h;
                    ch.setAttribute( HttpDirectoryService.KEY, new HttpDirectoryService( dirService ) );
                }
            }

            LOG.info( "starting jetty http server" );
            jetty.start();
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

        server = new Server();
        Connector connector = new SelectChannelConnector();
        connector.setPort(port);
        server.setConnectors(new Connector[]{connector});

        ContextHandler context = new ContextHandler();
        context.setContextPath("/");
        final ServletContext servletContext = context.getServletContext();
        server.setHandler(context);

        Handler handler = new AbstractHandler() {
            public void handle(String target, HttpServletRequest req, HttpServletResponse res, int dispatch) throws IOException, ServletException {
                try {
                    ((Request) req).setHandled(true);
                    HttpRequest httpRequest = new ServletRequestAdapter(req, res, servletContext);
                    HttpResponse httpResponse = new ServletResponseAdapter(res);
                    JettyHttpServer.this.listener.onMessage(httpRequest, httpResponse);
                } catch (IOException e) {
                    throw e;
                } catch (ServletException e) {
                    throw e;
                } catch (Exception e) {
                    throw new ServletException(e);
                }
            }
        };

        context.setHandler(handler);
    }
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

                    // in an absolute URI with host set to one of the ip addresses
                    selectConnector.setHost(host);
                    server.setConnectors(new Connector[] {selectConnector});
                }

                ContextHandler contextHandler = new ContextHandler();
                //contextHandler.setContextPath(contextPath);
                contextHandler.setContextPath("/");
                server.setHandler(contextHandler);

                SessionHandler sessionHandler = new SessionHandler();
                ServletHandler servletHandler = new ServletHandler();
                sessionHandler.addHandler(servletHandler);

                contextHandler.setHandler(sessionHandler);

                server.setStopAtShutdown(true);
                server.setSendServerVersion(sendServerVersion);
                server.start();
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

    public static ContextHandler getCurrentWebAppContext()
    {
        ContextHandler.SContext context=ContextHandler.getCurrentContext();
        if (context!=null)
        {
            ContextHandler handler = context.getContextHandler();
            if (handler instanceof WebAppContext)
                return (ContextHandler)handler;
        }
        return null;  
    }
View Full Code Here

Examples of org.mortbay.jetty.handler.ContextHandler

        return _recursive;
    }
    /* ------------------------------------------------------------ */
    private void deploy(String filename) throws Exception
    {
        ContextHandler context=createContext(filename);
        Log.info("Deploy "+filename+" -> "+ context);
        _contexts.addHandler(context);
        _currentDeployments.put(filename,context);
        if (_contexts.isStarted())
            context.start();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.