• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GracefulShutdownHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.undertow.server.handlers.GracefulShutdownHandler的典型用法代码示例。如果您正苦于以下问题:Java GracefulShutdownHandler类的具体用法?Java GracefulShutdownHandler怎么用?Java GracefulShutdownHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GracefulShutdownHandler类属于io.undertow.server.handlers包,在下文中一共展示了GracefulShutdownHandler类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: start

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
public static void start(String[] args) throws ServletException {
    Map<String, String> commands = Arrays.stream(args)
            .map(cmd -> cmd.split(REGEX_EQ))
            .collect(toMap(cmdArray -> cmdArray[IDX_ZERO], cmdArray -> cmdArray[IDX_ONE]));
    Config undertowConf = Configs.DEFAULT.undertow();
    Config httpConf = undertowConf.getConfig(KEY_HTTP);
    Logger logger = LoggerFactory.getLogger(Server.class);
    logger.debug("Commands to AdeptJ Runtime: {}", commands);
    int httpPort = handlePortAvailability(httpConf, logger);
    logger.info("Starting AdeptJ Runtime @port: [{}]", httpPort);
    printBanner(logger);
    DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo(undertowConf));
    manager.deploy();
    Builder builder = Undertow.builder();
    optimizeWorkerOptions(builder, undertowConf, logger);
    ServerOptions.build(builder, undertowConf);
    builder.addHttpListener(httpPort, httpConf.getString(KEY_HOST));
    enableHttp2(undertowConf, builder, logger);
    enableAJP(undertowConf, builder, logger);
    GracefulShutdownHandler rootHandler = rootHandler(headersHandler(manager.start(), undertowConf), undertowConf);
    Undertow server = builder.setHandler(rootHandler).build();
    server.start();
    Runtime.getRuntime().addShutdownHook(new ShutdownHook(server, manager, rootHandler));
    launchBrowser(commands, httpPort, logger);
    if (!Environment.isServerConfFileExists()) {
        createServerConfFile(logger);
    }
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:29,代码来源:Server.java


示例2: startImpl

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
protected void startImpl() {
    try {
        fathomDeploymentManager = createFathomDeploymentManager();
        HttpHandler fathomHandler = fathomDeploymentManager.start();

        String contextPath = settings.getContextPath();

        // create a handler than redirects non-context requests to the context
        PathHandler contextHandler = Handlers.path(Handlers.redirect(contextPath));

        // add the handler with the context prefix
        contextHandler.addPrefixPath(contextPath, fathomHandler);

        GracefulShutdownHandler rootHandler = new GracefulShutdownHandler(contextHandler);
        server = createServer(rootHandler);

        String version = server.getClass().getPackage().getImplementationVersion();
        log.info("Starting Undertow {}", version);

        server.start();
    } catch (Exception e) {
        throw new FathomException(e);
    }
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:25,代码来源:Server.java


示例3: start

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
@Override
public void start(ServerConfig serverConfig) throws Exception {
    shutdownHandler = new GracefulShutdownHandler(createHandler(dispatcher, serverConfig.contextPath()));
    
    final Builder builder = Undertow.builder()
        .setHandler(shutdownHandler)
        .addHttpListener(serverConfig.port(), serverConfig.host())
        
        // from undertow-edge benchmark
        .setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false) //don't send a keep-alive header for HTTP/1.1 requests, as it is not required
        ;
    
    configureServerPerformance(builder, serverConfig);
    
    server = builder.build();
    server.start();
}
 
开发者ID:MTDdk,项目名称:jawn,代码行数:18,代码来源:UndertowServer.java


示例4: HttpProtocolReceiver

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
public HttpProtocolReceiver(final UPID localAddress,
                            final Class<?> messageBaseClass,
                            final ManagedEventBus eventBus)
{
    this.localAddress = localAddress;
    this.messageBaseClass = messageBaseClass;
    this.eventBus = eventBus;

    final PathHandler pathHandler = new PathHandler();
    pathHandler.addPrefixPath(localAddress.getId(), new CanonicalPathHandler(new BlockingHandler(this)));

    this.shutdownHandler = new GracefulShutdownHandler(pathHandler);

    this.httpServer = Undertow.builder()
        .setIoThreads(2)
        .setWorkerThreads(16)
        .addHttpListener(localAddress.getPort(), localAddress.getHost())
        .setHandler(shutdownHandler)
        .build();
}
 
开发者ID:groupon,项目名称:jesos,代码行数:21,代码来源:HttpProtocolReceiver.java


示例5: start

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
@Override
public void start() {
    try {
        pippoDeploymentManager = createPippoDeploymentManager();
        HttpHandler pippoHandler = pippoDeploymentManager.start();

        HttpHandler contextHandler = createContextHandler(pippoHandler);
        GracefulShutdownHandler rootHandler = new GracefulShutdownHandler(contextHandler);
        server = createServer(rootHandler);

        String version = server.getClass().getPackage().getImplementationVersion();
        log.info("Starting Undertow Server {} on port {}", version, getSettings().getPort());

        server.start();
    } catch (Exception e) {
        throw new PippoRuntimeException(e);
    }
}
 
开发者ID:decebals,项目名称:pippo,代码行数:19,代码来源:UndertowServer.java


示例6: createServer

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
/**
 * Create And initialize undertow and handlers stack
 * @param appHandler application handler to use for this server
 * @return
 */
protected Undertow createServer(HttpHandler appHandler) {
	// Fifth Handler Session
	HttpHandler sessionHandler = sessionHandler(appHandler);
	// Fourth Handler crossOrigin
	HttpHandler crossOriginHandler = allowCrossOriginHandler(sessionHandler);
	// Third Handler exception
	HttpHandler exceptionHandler = exceptionHandler(crossOriginHandler);
	// Second Handler log
	HttpHandler logHandler = log(exceptionHandler);
	// First Handler GracefulShutdown
	GracefulShutdownHandler gracefulShutdownHandler = Handlers.gracefulShutdown(logHandler);

	Undertow.Builder builder = Undertow.builder();
	final int port = getPort();
	final String host = getHost();
	builder.addHttpListener(port, host);
	builder.setHandler(gracefulShutdownHandler);

	info("Listens on '" + host + ":" + port + "'");

	return builder.build();
}
 
开发者ID:kawane,项目名称:songbook,代码行数:28,代码来源:Server.java


示例7: buildGracefulShutdownHandler

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
/**
 * buildGracefulShutdownHandler
 *
 * @param paths
 * @return
 */
private static GracefulShutdownHandler buildGracefulShutdownHandler(PathHandler paths) {
    return new GracefulShutdownHandler(
            new RequestLimitingHandler(new RequestLimit(configuration.getRequestLimit()),
                    new AllowedMethodsHandler(
                            new BlockingHandler(
                                    new GzipEncodingHandler(
                                            new ErrorHandler(
                                                    new HttpContinueAcceptingHandler(paths)
                                            ), configuration.isForceGzipEncoding()
                                    )
                            ), // allowed methods
                            HttpString.tryFromString(RequestContext.METHOD.GET.name()),
                            HttpString.tryFromString(RequestContext.METHOD.POST.name()),
                            HttpString.tryFromString(RequestContext.METHOD.PUT.name()),
                            HttpString.tryFromString(RequestContext.METHOD.DELETE.name()),
                            HttpString.tryFromString(RequestContext.METHOD.PATCH.name()),
                            HttpString.tryFromString(RequestContext.METHOD.OPTIONS.name())
                    )
            )
    );
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:28,代码来源:Bootstrapper.java


示例8: UndertowServer

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
@Inject
public UndertowServer(final org.jooby.spi.HttpHandler dispatcher, final Config conf,
    final Provider<SSLContext> sslContext) throws Exception {

  awaitShutdown = conf.getDuration("undertow.awaitShutdown", TimeUnit.MILLISECONDS);
  boolean http2 = conf.getBoolean("server.http2.enabled");
  shutdown = new GracefulShutdownHandler(doHandler(dispatcher, conf));
  Undertow.Builder ubuilder = configure(conf, io.undertow.Undertow.builder())
      .addHttpListener(conf.getInt("application.port"),
          host(conf.getString("application.host")));

  ubuilder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2);

  boolean securePort = conf.hasPath("application.securePort");

  if (securePort) {
    ubuilder.addHttpsListener(conf.getInt("application.securePort"),
        host(conf.getString("application.host")), sslContext.get());
  }

  this.server = ubuilder.setHandler(shutdown)
      .build();
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:24,代码来源:UndertowServer.java


示例9: ShutdownHook

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
ShutdownHook(Undertow server, DeploymentManager manager, GracefulShutdownHandler shutdownHandler) {
    super(Constants.SHUTDOWN_HOOK_THREAD_NAME);
    this.server = server;
    this.manager = manager;
    this.shutdownHandler = shutdownHandler;
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:7,代码来源:ShutdownHook.java


示例10: rootHandler

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
private static GracefulShutdownHandler rootHandler(HttpHandler headersHandler, Config cfg) {
    return Handlers.gracefulShutdown(
            new RequestLimitingHandler(Integer.getInteger(SYS_PROP_MAX_CONCUR_REQ, cfg.getInt(KEY_MAX_CONCURRENT_REQS)),
                    new AllowedMethodsHandler(predicateHandler(headersHandler), allowedMethods(cfg))));
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:6,代码来源:Server.java


示例11: startPreview

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
/**
    * Creates and starts the server to serve the contents of OUTPUT_DIRECTORY on port
9090.
    */
   protected void startPreview() {
       ResourceHandler resourceHandler = resource(new PathResourceManager(Paths.get(OUTPUT_DIRECTORY), 100, true, true))
               .setDirectoryListingEnabled(false);
       FileErrorPageHandler errorHandler = new FileErrorPageHandler(Paths.get(OUTPUT_DIRECTORY).resolve("404.html"), StatusCodes.NOT_FOUND);
       errorHandler.setNext(resourceHandler);
       GracefulShutdownHandler shutdown = Handlers.gracefulShutdown(errorHandler);
       Undertow server = Undertow.builder().addHttpListener(port, "localhost")
               .setHandler(shutdown)
               .build();
       server.start();
   }
 
开发者ID:pawandubey,项目名称:griffin,代码行数:16,代码来源:Server.java


示例12: makeSharedHandlers

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
protected HttpHandler makeSharedHandlers(App root, OptionMap config,
		HttpHandler next) {
	HttpHandler hh = next;
	if (config.get(Config.METHOD_OVERRIDE)) {
		hh = new MethodOverrideHandler(hh);
	}
	hh = makeSessionHandler(root, config, hh);
	hh = makeFormHandler(root, config, hh);

	if (Config.isInDev(config)) {
		hh = Handlers.disableCache(hh);
	} else {
		GracefulShutdownHandler gsh = Handlers.gracefulShutdown(hh);
		root.stopOn(app -> {
			gsh.shutdown();
			try {
				gsh.awaitShutdown(config.get(
						Config.WAIT_FOR_GRACEFUL_SHUTDOWN, 500));
			} catch (InterruptedException e) {
				// ignore
			}
		});
		hh = gsh;
	}

	hh = new SecurityHandler(hh);
	return new Core(config, hh);
}
 
开发者ID:taichi,项目名称:siden,代码行数:29,代码来源:DefaultAppBuilder.java


示例13: addHandler

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
void addHandler(GracefulShutdownHandler handler)
{
    this.handlers.add(handler);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:5,代码来源:UndertowServerControl.java


示例14: gracefulShutdown

import io.undertow.server.handlers.GracefulShutdownHandler; //导入依赖的package包/类
/**
 * Returns a new handler that can be used to wait for all requests to finish before shutting down the server gracefully.
 *
 * @param next The next http handler
 * @return The graceful shutdown handler
 */
public static GracefulShutdownHandler gracefulShutdown(HttpHandler next) {
    return new GracefulShutdownHandler(next);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:Handlers.java



注:本文中的io.undertow.server.handlers.GracefulShutdownHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Ouya类代码示例发布时间:2022-05-22
下一篇:
Java OBJModel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap