@Before
  public void init() throws Exception {
    server = new Server();

    connector = new LocalConnector(server);
    connector
        .getConnectionFactory(HttpConfiguration.ConnectionFactory.class)
        .getHttpConfiguration()
        .setSendServerVersion(false);

    context = new ServletContextHandler();
    context.setContextPath("/context");
    context.setWelcomeFiles(new String[] {"index.html", "index.jsp", "index.htm"});

    server.setHandler(context);
    server.addConnector(connector);

    testdir.ensureEmpty();
    File resBase = testdir.getFile("docroot");
    FS.ensureDirExists(resBase);
    File data = new File(resBase, "data.txt");
    createFile(data, DATA);
    String resBasePath = resBase.getAbsolutePath();

    ServletHolder defholder = context.addServlet(DefaultServlet.class, "/");
    defholder.setInitParameter("acceptRanges", "true");
    defholder.setInitParameter("resourceBase", resBasePath);

    server.start();
  }
  @Before
  public void init() throws Exception {
    server = new Server();

    connector = new LocalConnector(server);
    connector
        .getConnectionFactory(HttpConfiguration.ConnectionFactory.class)
        .getHttpConfiguration()
        .setSendServerVersion(false);

    context = new ServletContextHandler();
    context.setContextPath("/context");
    context.setWelcomeFiles(new String[] {"index.html", "index.jsp", "index.htm"});

    server.setHandler(context);
    server.addConnector(connector);

    server.start();
  }
 private void createWebAppContext() {
   ServletContextHandler context;
   // Add web-app. Check to see if we're in development mode. If so, we don't
   // add the normal web-app location, but the web-app in the project directory.
   if (Boolean.getBoolean("developmentMode")) {
     System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode"));
     context =
         new WebAppContext(
             contexts,
             pluginDir.getParentFile().getParentFile().getParentFile().getParent()
                 + File.separator
                 + "src"
                 + File.separator
                 + "web",
             "/");
   } else {
     context =
         new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/");
   }
   context.setWelcomeFiles(new String[] {"index.jsp"});
 }
Exemple #4
0
  private ServletContextHandler getTutorHandler() throws IOException {
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setAttribute("RascalEvaluator", eval);
    context.addServlet(new ServletHolder(new TutorDefaultHttpServlet()), "/");
    context.addServlet(new ServletHolder(new Show()), "/show");
    context.addServlet(new ServletHolder(new ValidateExam()), "/validateExam");
    context.addServlet(new ServletHolder(new Validate()), "/validate");
    context.addServlet(new ServletHolder(new Eval()), "/eval");
    context.addServlet(new ServletHolder(new Edit()), "/edit");
    context.addServlet(new ServletHolder(new Save()), "/save");
    context.addServlet(new ServletHolder(new Compile()), "/compile");

    URI baseURI = getResolverRegistry().getResourceURI(URIUtil.rootScheme(BASE_SCHEME));

    System.err.println("resourceBase = " + baseURI);
    String resourceBase = baseURI.toASCIIString();
    context.setResourceBase(resourceBase);
    context.setAttribute("ResourceBase", resourceBase);

    String welcome[] = {BASE_SCHEME + ":///index.html"};
    context.setWelcomeFiles(welcome);

    return context;
  }