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


Java Server.setSendServerVersion方法代码示例

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


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

示例1: doStart

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
public static void doStart() throws Exception {

        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(JETTY_SERVER_PORT);

        String webDefault = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/webdefault.xml";
        Resource web = resolver.getResources(webDefault)[0];
        String descriptor = web.getFile().getAbsolutePath();

        String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/" + SpiderJetty.class.getName() + ".class";
        Resource resource = resolver.getResources(pattern)[0];
        String resourcePath = resource.getFile().getAbsolutePath().replaceAll("target.*$", "") + "webapp";

        WebAppContext context = new WebAppContext();
        context.setContextPath("/");
        context.setDefaultsDescriptor(descriptor);
        context.setResourceBase("file:" + resourcePath);
        context.setClassLoader(Thread.currentThread().getContextClassLoader());

        server.setConnectors(new Connector[]{connector});
        server.setHandler(context);

        server.setStopAtShutdown(true);
        server.setSendServerVersion(false);
        server.setSendDateHeader(false);
        server.setGracefulShutdown(1000);


        try {
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:MartinDai,项目名称:TBSpider,代码行数:37,代码来源:SpiderJetty.java

示例2: setupHTTPServer

import org.mortbay.jetty.Server; //导入方法依赖的package包/类
private void setupHTTPServer() throws IOException {
  TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
  TProcessor processor = new Hbase.Processor<Hbase.Iface>(handler);
  TServlet thriftHttpServlet = new ThriftHttpServlet(processor, protocolFactory, realUser,
      conf, hbaseHandler, securityEnabled, doAsEnabled);

  httpServer = new Server();
  // Context handler
  Context context = new Context(httpServer, "/", Context.SESSIONS);
  context.setContextPath("/");
  String httpPath = "/*";
  httpServer.setHandler(context);
  context.addServlet(new ServletHolder(thriftHttpServlet), httpPath);

  // set up Jetty and run the embedded server
  Connector connector = new SelectChannelConnector();
  if(conf.getBoolean(THRIFT_SSL_ENABLED, false)) {
    SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
    String keystore = conf.get(THRIFT_SSL_KEYSTORE_STORE);
    String password = HBaseConfiguration.getPassword(conf,
        THRIFT_SSL_KEYSTORE_PASSWORD, null);
    String keyPassword = HBaseConfiguration.getPassword(conf,
        THRIFT_SSL_KEYSTORE_KEYPASSWORD, password);
    sslConnector.setKeystore(keystore);
    sslConnector.setPassword(password);
    sslConnector.setKeyPassword(keyPassword);
    connector = sslConnector;
  }
  String host = getBindAddress(conf).getHostAddress();
  connector.setPort(listenPort);
  connector.setHost(host);
  connector.setHeaderBufferSize(1024 * 64);
  httpServer.addConnector(connector);

  if (doAsEnabled) {
    ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
  }

  // Set the default max thread number to 100 to limit
  // the number of concurrent requests so that Thrfit HTTP server doesn't OOM easily.
  // Jetty set the default max thread number to 250, if we don't set it.
  //
  // Our default min thread number 2 is the same as that used by Jetty.
  int minThreads = conf.getInt(HTTP_MIN_THREADS, 2);
  int maxThreads = conf.getInt(HTTP_MAX_THREADS, 100);
  QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
  threadPool.setMinThreads(minThreads);
  httpServer.setThreadPool(threadPool);

  httpServer.setSendServerVersion(false);
  httpServer.setSendDateHeader(false);
  httpServer.setStopAtShutdown(true);

  LOG.info("Starting Thrift HTTP Server on " + Integer.toString(listenPort));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:56,代码来源:ThriftServerRunner.java


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