Package org.mortbay.jetty.servlet

Examples of org.mortbay.jetty.servlet.Context


        Server server = new Server(8080);
        DebugHandler debug = new DebugHandler();
        debug.setOutputStream(System.err);
        server.setHandler(debug);
       
        Context context = new Context(debug,"/",Context.SESSIONS);
        FilterHolder gzip=context.addFilter(IncludableGzipFilter.class,"/*",0);
        gzip.setInitParameter("uncheckedPrintWriter","true");
        context.addServlet(new ServletHolder(new Dump()), "/*");
       
        server.start();
        server.join();
    }
View Full Code Here


            Server httpServer = new Server();
            httpServer.setConnectors(new Connector[] { connector });
            httpServer.setThreadPool(threadPool);
            httpServer.setSendServerVersion(false);
            httpServer.setSendDateHeader(false);
            Context context = new Context(httpServer, "/", Context.NO_SESSIONS);
            context.setAttribute(VoldemortServletContextListener.SERVER_KEY, server);
            context.setAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY,
                                 velocityEngine);
            context.addServlet(new ServletHolder(new AdminServlet(server, velocityEngine)),
                               "/admin");
            context.addServlet(new ServletHolder(new StoreServlet(requestHandler)), "/stores");
            context.addServlet(new ServletHolder(new ReadOnlyStoreManagementServlet(server,
                                                                                    velocityEngine)),
                               "/read-only/mgmt");
            context.addServlet(new ServletHolder(new StatusServlet(server, velocityEngine)),
                               "/server-status");
            this.context = context;
            this.httpServer = httpServer;
            this.httpServer.start();
            logger.info("HTTP service started on port " + this.port);
View Full Code Here

    }

    protected void createContext( Server server, File repositoryDirectory )
        throws IOException
    {
        Context root = new Context( server, "/", Context.SESSIONS );
        root.setResourceBase( repositoryDirectory.getAbsolutePath() );
        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
        root.addServlet( servletHolder, "/*" );
    }
View Full Code Here

        throws Exception
    {
        Server server = new Server( getTestRepositoryPort() );

        String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
        Context root = new Context( server, "/", Context.SESSIONS );
        root.setResourceBase( localRepositoryPath );
        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
        servletHolder.setInitParameter( "gzip", "true" );
        root.addServlet( servletHolder, "/*" );
        addConnectors( server );
        server.start();

        try
        {
View Full Code Here

    {
        Server server = new Server( 0 );

        SecurityHandler sh = createSecurityHandler();

        Context root = new Context( Context.SESSIONS );
        root.setContextPath( "/" );
        root.addHandler( sh );
        root.setResourceBase( localRepositoryPath );
        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
        root.addServlet( servletHolder, "/*" );

        server.setHandler( root );
        addConnectors( server );
        return server;
    }
View Full Code Here

            makeHugeFile( hugeFile );
        }

        server = new Server( 0 );

        Context root = new Context( server, "/", Context.SESSIONS );
        root.setResourceBase( new File( getBasedir(), "/target" ).getAbsolutePath() );
        ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
        root.addServlet( servletHolder, "/*" );

        server.start();

        try
        {
View Full Code Here

            makeHugeFile( hugeFile );
        }

        server = new Server( 0 );

        Context root = new Context( server, "/", Context.SESSIONS );
        root.setResourceBase( new File( getBasedir(), "/target" ).getAbsolutePath() );
        ServletHolder servletHolder = new ServletHolder( new HttpServlet()
        {
            @Override
            protected void doGet( HttpServletRequest req, HttpServletResponse resp )
                throws ServletException, IOException
            {
                FileInputStream fis = new FileInputStream( hugeFile );

                byte[] buffer = new byte[8192];
                int len = 0;
                while ( ( len = fis.read( buffer ) ) != -1 )
                {
                    resp.getOutputStream().write( buffer, 0, len );
                }
                fis.close();
            }
        } );
        root.addServlet( servletHolder, "/*" );

        server.start();

        try
        {
View Full Code Here

  }
 
  public EmbeddedWebServer(String host, int port) {
    server = new Server();
    handler = new ContextHandlerCollection();
    root = new Context(handler, "/", new SessionHandler(), null, null, null);
   
    if (EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTORE))
        || EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_KEYSTOREPASS))
        || EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTORE))
        || EMPTY.equals(Monitor.getSystemConfiguration().get(Property.MONITOR_SSL_TRUSTSTOREPASS))) {
View Full Code Here

   */
  private void fixupLogsServletLocation() {
    // Must be same as up in hadoop.
    final String logsContextPath = "/logs";
    // Now, put my logs in place of hadoops... disable old one first.
    Context oldLogsContext = null;
    for (Map.Entry<Context, Boolean> e : defaultContexts.entrySet()) {
      if (e.getKey().getContextPath().equals(logsContextPath)) {
        oldLogsContext = e.getKey();
        break;
      }
    }
    if (oldLogsContext != null) {
      this.defaultContexts.put(oldLogsContext, Boolean.FALSE);
    }
    // Now do my logs.
    // Set up the context for "/logs/" if "hbase.log.dir" property is defined.
    String logDir = System.getProperty("wasp.log.dir");
    if (logDir != null) {
      // This is a little presumptious but seems to work.
      Context logContext =
        new Context((ContextHandlerCollection)this.webServer.getHandler(),
          logsContextPath);
      logContext.setResourceBase(logDir);
      logContext.addServlet(DefaultServlet.class, "/");
      defaultContexts.put(logContext, true);
    }
  }
View Full Code Here

    @Before
    public final void setUp() throws Exception {
        int port = FreePortScanner.getFreePort();
        connectionUri = new URI("http", null, "localhost", port, null, null, null);
        jettyServer = new Server(port);
        jettyContext = new Context(jettyServer, "/");
        messageSender = createMessageSender();
        if (messageSender instanceof InitializingBean) {
            ((InitializingBean) messageSender).afterPropertiesSet();
        }
        XMLUnit.setIgnoreWhitespace(true);
View Full Code Here

TOP

Related Classes of org.mortbay.jetty.servlet.Context

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.