Package org.mortbay.jetty.servlet

Examples of org.mortbay.jetty.servlet.Context


  }

  @Test
  @TestServlet
  public void testJetty() throws Exception {
    Context context = new Context();
    context.setContextPath("/");
    context.addServlet(MyServlet.class, "/bar");
    Server server = getJettyServer();
    server.addHandler(context);
    server.start();
    URL url = new URL(getJettyURL(), "/bar");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
View Full Code Here


    server.setThreadPool(threads);
    server.setConnectors(new Connector[] { conn });
    server.setStopAtShutdown( true );
   
    // Initialize the servlets
    Context root = new Context( server, context, Context.SESSIONS );
   
    root.addServlet( Servlet404.class, "/*" );
    dispatchFilter = root.addFilter( SolrDispatchFilter.class, "*", Handler.REQUEST );
  }
View Full Code Here

  protected void addDefaultApps(ContextHandlerCollection parent,
      final String appDir) throws IOException {
    // set up the context for "/logs/" if "hadoop.log.dir" property is defined.
    String logDir = System.getProperty("hadoop.log.dir");
    if (logDir != null) {
      Context logContext = new Context(parent, "/logs");
      logContext.setResourceBase(logDir);
      logContext.addServlet(AdminAuthorizedServlet.class, "/");
      logContext.setDisplayName("logs");
      setContextAttributes(logContext);
      defaultContexts.put(logContext, true);
    }
    // set up the context for "/static/*"
    Context staticContext = new Context(parent, "/static");
    staticContext.setResourceBase(appDir + "/static");
    staticContext.addServlet(DefaultServlet.class, "/*");
    staticContext.setDisplayName("static");
    setContextAttributes(staticContext);
    defaultContexts.put(staticContext, true);
  }
View Full Code Here

    LOG.info("Added filter " + name + " (class=" + classname
        + ") to context " + webAppContext.getDisplayName());
    final String[] ALL_URLS = { "/*" };
    for (Map.Entry<Context, Boolean> e : defaultContexts.entrySet()) {
      if (e.getValue()) {
        Context ctx = e.getKey();
        defineFilter(ctx, name, classname, parameters, ALL_URLS);
        LOG.info("Added filter " + name + " (class=" + classname
            + ") to context " + ctx.getDisplayName());
      }
    }
    filterNames.add(name);
  }
View Full Code Here

    connector = new SocketConnector();
    connector.setPort(new Integer(port));
    connector.setHost("127.0.0.1");
    server = new Server();
    server.addConnector(connector);
    Context root = new Context(server, "/", Context.SESSIONS);
    root.addServlet(new ServletHolder(new JezebelResmon()), "/resmon");
    root.addServlet(new ServletHolder(new JezebelDispatch()), "/dispatch/*");

    logger.info("Starting server on port " + port);
    try { server.start(); }
    catch (Exception e) { e.printStackTrace(); }
  }
View Full Code Here

        String contextA = "/contextA";
        String contextB = "/contextB";
        String servletMapping = "/server";
        int port = random.nextInt(50000) + 10000;
        TerracottaJettyServer server = new TerracottaJettyServer(port);
        Context ctxA = server.addContext(contextA);
        ctxA.addServlet(TestServletA.class, servletMapping);
        Context ctxB = server.addContext(contextB);
        ctxB.addServlet(TestServletB.class, servletMapping);
        server.start();
        try
        {
            HttpClient client = new HttpClient();
            client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
View Full Code Here

        String contextPath = "";
        String servletMapping = "/server";
        int port = random.nextInt(50000) + 10000;
        int scavengePeriod = 3;
        TerracottaJettyServer server = new TerracottaJettyServer(port, 1, scavengePeriod);
        Context context = server.addContext(contextPath);
        context.addServlet(TestServlet.class, servletMapping);
        server.start();
        try
        {
            HttpClient client = new HttpClient();
            client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
View Full Code Here

        String contextA = "/contextA";
        String contextB = "/contextB";
        String servletMapping = "/server";
        int port = random.nextInt(50000) + 10000;
        TerracottaJettyServer server = new TerracottaJettyServer(port);
        Context ctxA = server.addContext(contextA);
        ctxA.addServlet(TestServletA.class, servletMapping);
        Context ctxB = server.addContext(contextB);
        ctxB.addServlet(TestServletB.class, servletMapping);
        server.start();
        try
        {
            HttpClient client = new HttpClient();
            client.setConnectorType(HttpClient.CONNECTOR_SOCKET);
View Full Code Here

        server.start();
    }

    public Context addContext(String contextPath)
    {
        Context context = new Context(contexts, contextPath);

        TerracottaSessionManager sessionManager = new TestTerracottaSessionManager();
        sessionManager.setIdManager(sessionIdManager);
        sessionManager.setMaxInactiveInterval(maxInactivePeriod);
        sessionManager.setScavengePeriodMs(TimeUnit.SECONDS.toMillis(scavengePeriod));

        SessionHandler sessionHandler = new TerracottaSessionHandler(sessionManager);
        sessionManager.setSessionHandler(sessionHandler);
        context.setSessionHandler(sessionHandler);

        return context;
    }
View Full Code Here

        {
          connector.setPort( _PORT );
        }
       
        server.addConnector(connector);
        Context context = new Context(server, "", Context.NO_SECURITY | Context.NO_SESSIONS);
        ServletHolder h = new ServletHolder(new HttpServlet() {
            private static final long serialVersionUID = 1L;

            @Override
            protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
                resp.setContentType("text/plain");
                resp.setStatus(HttpServletResponse.SC_OK);
                resp.getWriter().write("ok\n");
            }

            @Override
            protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
                resp.setContentType("text/plain");
                resp.setStatus(HttpServletResponse.SC_OK);
                resp.getWriter().write("ok\n");
            }

        });
        context.addServlet(h, "/ping");
        server.start();
        _PORT = connector.getLocalPort();
        _url = String.format("http://localhost:%d/ping", _PORT);
    }
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.