Package org.mortbay.jetty.servlet

Examples of org.mortbay.jetty.servlet.WebApplicationContext


            }

            NCSARequestLog log = new NCSARequestLog();
            server.setRequestLog(log);

            WebApplicationContext context = server.addWebApplication(contextPath, webappPath);
           
            for (String virtualHost : virtualHosts) {
        context.addVirtualHost(virtualHost);
      }

            context.setDefaultsDescriptor(webDefaults);

            server.start();

            return server;
        }
View Full Code Here


   * @param classname The class name for the servlet
   */
  public <T extends HttpServlet>
  void addServlet(String name, String pathSpec,
                  Class<T> servletClass) {
    WebApplicationContext context = webAppContext;
    try {
      if (name == null) {
        context.addServlet(pathSpec, servletClass.getName());
      } else {
        context.addServlet(name, pathSpec, servletClass.getName());
      }
    } catch (ClassNotFoundException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
    } catch (InstantiationException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
View Full Code Here

    listener.setMaxThreads(numThreads);
    webServer.addListener(listener);
    NCSARequestLog ncsa = new NCSARequestLog();
    ncsa.setLogLatency(true);
    webServer.setRequestLog(ncsa);
    WebApplicationContext context =
      webServer.addWebApplication("/api", InfoServer.getWebAppDir("rest"));
    context.addServlet("stacks", "/stacks",
      StatusHttpServer.StackServlet.class.getName());
    context.addServlet("logLevel", "/logLevel",
      org.apache.hadoop.log.LogLevel.Servlet.class.getName());
    webServer.start();
  }
View Full Code Here

   * @param pathSpec The path spec for the servlet
   * @param servletClass The servlet class
   */
  public <T extends HttpServlet> void addServlet(String name, String pathSpec,
      Class<T> servletClass) {
    WebApplicationContext context = webAppContext;
    try {
      if (name == null) {
        context.addServlet(pathSpec, servletClass.getName());
      } else {
        context.addServlet(name, pathSpec, servletClass.getName());
      }
    } catch (ClassNotFoundException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
    } catch (InstantiationException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
View Full Code Here

   * @param dir The directory containing the context
   * @param isFiltered if true, the servlet is added to the filter path mapping
   * @throws IOException
   */
  protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException {
    WebApplicationContext webAppCtx = webServer.addWebApplication(pathSpec, dir);
    defaultContexts.put(webAppCtx, isFiltered);
  }
View Full Code Here

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

   * @param servletClass The servlet class
   */
  public <T extends HttpServlet>
  void addServlet(String name, String pathSpec,
                  Class<T> servletClass) {
    WebApplicationContext context = webAppContext;
    try {
      if (name == null) {
        context.addServlet(pathSpec, servletClass.getName());
      } else {
        context.addServlet(name, pathSpec, servletClass.getName());
      }
    } catch (ClassNotFoundException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
    } catch (InstantiationException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
View Full Code Here

                            if (!location.endsWith("/")) {
                                location = location + "/";
                            }

                            // load the application
                            WebApplicationContext ctx = server.addWebApplication(appInfo.mountPoint, location);
                            ctx.setAttribute("_serverId", appInfo.server);

                            // set the session manager
                            SessionManager sm = new HashSessionManager();
                            ctx.getWebApplicationHandler().setSessionManager(sm);
                           
                            // set the virtual hosts
                            for (String vh: virtualHosts) {
                                ctx.addVirtualHost(vh);
                            }

                            // set the init parameters
                            for (Map.Entry<String, String> entry: initParameters.entrySet()) {
                                ctx.setInitParameter(entry.getKey(), entry.getValue());
                            }

                        } catch (IOException e) {
                            Debug.logError(e, "Problem mounting application [" + appInfo.name + " / " + appInfo.location + "]", module);
                        }
View Full Code Here

            server.addListener(socketListener);

            NCSARequestLog log = new NCSARequestLog();
            server.setRequestLog(log);

            WebApplicationContext context = server.addWebApplication(_contextPath, _warPath);

            context.setDefaultsDescriptor("src/test/conf/webdefault.xml");

            server.start();

            return server;
        }
View Full Code Here

   */
  public <T extends HttpServlet>
   void addServlet(String name, String pathSpec,
                   Class<T> servletClass) {
  
    WebApplicationContext context = webAppContext;
    try {
      if (name == null) {
        context.addServlet(pathSpec, servletClass.getName());
      } else {
        context.addServlet(name, pathSpec, servletClass.getName());
      }
    } catch (ClassNotFoundException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
    } catch (InstantiationException ex) {
      throw makeRuntimeException("Problem instantiating class", ex);
View Full Code Here

TOP

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

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.