當前位置: 首頁>>代碼示例>>Java>>正文


Java Server.setStopAtShutdown方法代碼示例

本文整理匯總了Java中org.mortbay.jetty.Server.setStopAtShutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.setStopAtShutdown方法的具體用法?Java Server.setStopAtShutdown怎麽用?Java Server.setStopAtShutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mortbay.jetty.Server的用法示例。


在下文中一共展示了Server.setStopAtShutdown方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ServerProxyImpl

import org.mortbay.jetty.Server; //導入方法依賴的package包/類
/**
 * Default constructor. Creates a new Jetty server with a standard connector
 * listening on a given port.
 * 
 * @param userRealmsList
 * 
 * @param port default connector port number.
 * @param maxIdleTime default connector maximum idle time of for each
 *            connection.
 */
public ServerProxyImpl(List connectors, List userRealmsList, RequestLog requestLog,
        File jettyXml)
{
    server = new Server();
    server.setStopAtShutdown(true);

    this.connectors = connectors;
    this.userRealms = userRealmsList;
    this.requestLog = requestLog;
    this.jettyXml = jettyXml;
    configure();
}
 
開發者ID:iMartinezMateu,項目名稱:openbravo-pos,代碼行數:23,代碼來源:ServerProxyImpl.java

示例2: 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

示例3: main

import org.mortbay.jetty.Server; //導入方法依賴的package包/類
public static void main(String[] args) {
    try {
        String confPath = args[0];

        confPath = confPath.trim();

        Properties conf = new Properties();
        InputStream is = new FileInputStream(new File(confPath + "/conf/lts-admin.cfg"));
        conf.load(is);
        String port = conf.getProperty("port");
        if (port == null || port.trim().equals("")) {
            port = "8081";
        }

        Server server = new Server(Integer.parseInt(port));
        WebAppContext webapp = new WebAppContext();
        webapp.setWar(confPath + "/lts-admin.war");
        Map<String, String> initParams = new HashMap<String, String>();
        initParams.put("lts.admin.config.path", confPath + "/conf");
        webapp.setInitParams(initParams);
        server.setHandler(webapp);
        server.setStopAtShutdown(true);
        server.start();

        System.out.println("LTS-Admin started. http://" + NetUtils.getLocalHost() + ":" + port + "/index.htm");

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
開發者ID:WenZuHuai,項目名稱:light-task-scheduler,代碼行數:32,代碼來源:JettyContainer.java

示例4: JettyServer

import org.mortbay.jetty.Server; //導入方法依賴的package包/類
public JettyServer(int port, HttpsConfiguration httpsConf)
{
    server = new Server();

    SslSelectChannelConnector connector = new SslSelectChannelConnector();
    connector.setPort(port);
    connector.setKeystore(httpsConf.getServerKeystorePath());
    connector.setKeyPassword(httpsConf.getServerKeystorePassword());

    if ( httpsConf.isVerifyPeerCert() )
    {
        connector.setTruststore(httpsConf.getTruststorePath());
        connector.setTrustPassword(httpsConf.getTruststorePassword());
        connector.setNeedClientAuth(true);
    }

    connector.setWantClientAuth(httpsConf.isRequireClientCert());

    connector.setAcceptors(8);
    connector.setMaxIdleTime(5000);
    connector.setAcceptQueueSize(32);

    server.addConnector(connector);
    server.setStopAtShutdown(true);

    DefaultResourceConfig config = new DefaultResourceConfig(JettyServer.RestService.class);
    ServletContainer container = new ServletContainer(config);

    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(new ServletHolder(container), "/*");
}
 
開發者ID:dcos,項目名稱:exhibitor,代碼行數:32,代碼來源:JettyServer.java

示例5: 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.setStopAtShutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。