當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。