当前位置: 首页>>代码示例>>Java>>正文


Java Context.setResourceBase方法代码示例

本文整理汇总了Java中org.mortbay.jetty.servlet.Context.setResourceBase方法的典型用法代码示例。如果您正苦于以下问题:Java Context.setResourceBase方法的具体用法?Java Context.setResourceBase怎么用?Java Context.setResourceBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mortbay.jetty.servlet.Context的用法示例。


在下文中一共展示了Context.setResourceBase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
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(StaticServlet.class, "/");
    defaultContexts.put(logContext, true);
  }
  // set up the context for "/static/*"
  Context staticContext = new Context(parent, "/static");
  staticContext.setResourceBase(appDir + "/static");
  staticContext.addServlet(StaticServlet.class, "/*");
  defaultContexts.put(staticContext, true);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:22,代码来源:HttpServer.java

示例2: start

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
public void start() throws Exception {
  this.jetty.addConnector(connector);

  ServletHandler servletHandler = new ServletHandler();

  String filterName = "MyriadGuiceFilter";
  FilterHolder holder = new FilterHolder(filter);
  holder.setName(filterName);

  FilterMapping filterMapping = new FilterMapping();
  filterMapping.setPathSpec("/*");
  filterMapping.setDispatches(Handler.ALL);
  filterMapping.setFilterName(filterName);

  servletHandler.addFilter(holder, filterMapping);

  Context context = new Context();
  context.setServletHandler(servletHandler);
  context.addServlet(DefaultServlet.class, "/");

  String staticDir = this.getClass().getClassLoader().getResource("webapp/public").toExternalForm();
  context.setResourceBase(staticDir);

  this.jetty.addHandler(context);
  this.jetty.start();
}
 
开发者ID:apache,项目名称:incubator-myriad,代码行数:27,代码来源:MyriadWebServer.java

示例3: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
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);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:26,代码来源:HttpServer.java

示例4: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
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(DefaultServlet.class, "/");
    defaultContexts.put(logContext, true);
  }
  // set up the context for "/static/*"
  Context staticContext = new Context(parent, "/static");
  staticContext.setResourceBase(appDir + "/static");
  staticContext.addServlet(DefaultServlet.class, "/*");
  defaultContexts.put(staticContext, true);
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:22,代码来源:HttpServer.java

示例5: main

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Sets up and runs server.
 * @param args
 */
public static void main(String[] args)
{
    Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.addConnector(connector);

    Context htmlContext = new Context(server, "/", Context.SESSIONS);
    ResourceHandler htmlHandler = new ResourceHandler();
    htmlHandler.setResourceBase("web");
    htmlContext.setHandler(htmlHandler);

    Context servletContext = new Context(server, "/", Context.SESSIONS);
    ServletHolder holder = new ServletHolder(new DwrServlet());
    holder.setInitParameter("activeReverseAjaxEnabled", "true");
    holder.setInitParameter("debug", "true");
    servletContext.addServlet(holder, "/dwr/*");
    servletContext.setResourceBase("web");

    try
    {
        JettyShutdown.addShutdownHook(server);
        server.start();
        server.join();
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:JettyLauncher.java

示例6: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
protected void addDefaultApps(ContextHandlerCollection parent,
    final String appDir, Configuration conf) 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, "/*");
    if (conf.getBoolean(
        CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES,
        CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) {
      logContext.getInitParams().put(
          "org.mortbay.jetty.servlet.Default.aliases", "true");
    }
    logContext.setDisplayName("logs");
    setContextAttributes(logContext, conf);
    addNoCacheFilter(webAppContext);
    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, conf);
  defaultContexts.put(staticContext, true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:HttpServer.java

示例7: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
protected void addDefaultApps(ContextHandlerCollection parent,
    final String appDir, Configuration conf) 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, "/*");
    if (conf.getBoolean(
        CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES,
        CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) {
      @SuppressWarnings("unchecked")
      Map<String, String> params = logContext.getInitParams();
      params.put(
          "org.mortbay.jetty.servlet.Default.aliases", "true");
    }
    logContext.setDisplayName("logs");
    setContextAttributes(logContext, conf);
    addNoCacheFilter(webAppContext);
    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, conf);
  defaultContexts.put(staticContext, true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:HttpServer2.java

示例8: addDefaultApps

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
protected void addDefaultApps(ContextHandlerCollection parent,
    final String appDir, Configuration conf) throws IOException {
  // set up the context for "/logs/" if "hadoop.log.dir" property is defined.
  String logDir = this.logDir;
  if (logDir == null) {
      logDir = System.getProperty("hadoop.log.dir");
  }
  if (logDir != null) {
    Context logContext = new Context(parent, "/logs");
    logContext.setResourceBase(logDir);
    logContext.addServlet(AdminAuthorizedServlet.class, "/*");
    if (conf.getBoolean(
        ServerConfigurationKeys.HBASE_JETTY_LOGS_SERVE_ALIASES,
        ServerConfigurationKeys.DEFAULT_HBASE_JETTY_LOGS_SERVE_ALIASES)) {
      @SuppressWarnings("unchecked")
      Map<String, String> params = logContext.getInitParams();
      params.put(
          "org.mortbay.jetty.servlet.Default.aliases", "true");
    }
    logContext.setDisplayName("logs");
    setContextAttributes(logContext, conf);
    addNoCacheFilter(webAppContext);
    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, conf);
  defaultContexts.put(staticContext, true);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:HttpServer.java

示例9: fixupLogsServletLocation

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Fixup where the logs app points, make it point at hbase logs rather than
 * hadoop logs.
 */
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("hbase.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);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:32,代码来源:InfoServer.java

示例10: fixupLogsServletLocation

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
 * Fixup where the logs app points, make it point at hbase logs rather than
 * hadoop logs.
 */
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("hbase.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, "/");
    HttpServerUtil.constrainHttpMethods(logContext);
    defaultContexts.put(logContext, true);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:33,代码来源:InfoServer.java

示例11: WebServer

import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
public WebServer(int httpport, DataStore data, MetadataStore metadata) throws IOException, URISyntaxException {
    super(httpport);

    extractWebUI();

    this.data = data;
    this.metadata = metadata;

    // Initialize Velocity template engine
    try {
        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute");
        Velocity.setProperty("runtime.log.logsystem.log4j.logger", "edu.berkeley.xtrace.server.XTraceServer");
        Velocity.setProperty("file.resource.loader.path", webui + "/templates");
        Velocity.setProperty("file.resource.loader.cache", "true");
        Velocity.init();
    } catch (Exception e) {
        LOG.warn("Failed to initialize Velocity", e);
    }

    // Create Jetty server
    Context context = new Context(this, "/");

    // Create a CGI servlet for scripts in webui/cgi-bin
    ServletHolder cgiHolder = new ServletHolder(new CGI());
    cgiHolder.setInitParameter("cgibinResourceBase", webui + "/cgi-bin");

    // Pass any special PATH setting on to the execution environment
    if (System.getenv("PATH") != null)
        cgiHolder.setInitParameter("Path", System.getenv("PATH"));

    context.addServlet(cgiHolder, "*.cgi");
    context.addServlet(cgiHolder, "*.pl");
    context.addServlet(cgiHolder, "*.py");
    context.addServlet(cgiHolder, "*.rb");
    context.addServlet(cgiHolder, "*.tcl");
    context.addServlet(new ServletHolder(new GetReportsServlet()), "/reports/*");
    context.addServlet(new ServletHolder(new TagServlet()), "/tag/*");
    context.addServlet(new ServletHolder(new TitleServlet()), "/title/*");
    context.addServlet(new ServletHolder(new TitleLikeServlet()), "/titleLike/*");

    // JSON APIs for interactive visualization
    context.addServlet(new ServletHolder(new GetJSONReportsServlet()), "/interactive/reports/*");
    context.addServlet(new ServletHolder(new GetOverlappingTasksServlet()), "/interactive/overlapping/*");
    context.addServlet(new ServletHolder(new GetTagsForTaskServlet()), "/interactive/tags/*");
    context.addServlet(new ServletHolder(new GetTasksForTags()), "/interactive/taggedwith/*");

    context.setResourceBase(webui + "/html");
    context.addServlet(new ServletHolder(new IndexServlet()), "/");
}
 
开发者ID:brownsys,项目名称:tracing-framework,代码行数:50,代码来源:WebServer.java


注:本文中的org.mortbay.jetty.servlet.Context.setResourceBase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。