org.eclipse.jetty.server.Server.addLifeCycleListener()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中org.eclipse.jetty.server.Server.addLifeCycleListener()方法的一些代码示例,展示了Server.addLifeCycleListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.addLifeCycleListener()方法的具体详情如下:
包路径:org.eclipse.jetty.server.Server
类名称:Server
方法名:addLifeCycleListener

Server.addLifeCycleListener介绍

暂无

代码示例

代码示例来源:origin: dropwizard/dropwizard

@Override
protected void run(Environment environment, Namespace namespace, T configuration) throws Exception {
  final Server server = configuration.getServerFactory().build(environment);
  try {
    server.addLifeCycleListener(new LifeCycleListener());
    cleanupAsynchronously();
    server.start();
  } catch (Exception e) {
    LOGGER.error("Unable to start server, shutting down", e);
    try {
      server.stop();
    } catch (Exception e1) {
      LOGGER.warn("Failure during stop server", e1);
    }
    try {
      cleanup();
    } catch (Exception e2) {
      LOGGER.warn("Failure during cleanup", e2);
    }
    throw e;
  }
}

代码示例来源:origin: dropwizard/dropwizard

protected Server buildServer(LifecycleEnvironment lifecycle,
               ThreadPool threadPool) {
  final Server server = new Server(threadPool);
  server.addLifeCycleListener(buildSetUIDListener());
  lifecycle.attach(server);
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setServer(server);
  errorHandler.setShowStacks(false);
  server.addBean(errorHandler);
  server.setStopAtShutdown(true);
  server.setStopTimeout(shutdownGracePeriod.toMilliseconds());
  return server;
}

代码示例来源:origin: apache/incubator-druid

server.setStopTimeout(gracefulStop);
server.addLifeCycleListener(new LifeCycle.Listener()

代码示例来源:origin: io.dropwizard/dropwizard-core

@Override
protected void run(Environment environment, Namespace namespace, T configuration) throws Exception {
  final Server server = configuration.getServerFactory().build(environment);
  try {
    server.addLifeCycleListener(new LifeCycleListener());
    cleanupAsynchronously();
    server.start();
  } catch (Exception e) {
    LOGGER.error("Unable to start server, shutting down", e);
    try {
      server.stop();
    } catch (Exception e1) {
      LOGGER.warn("Failure during stop server", e1);
    }
    try {
      cleanup();
    } catch (Exception e2) {
      LOGGER.warn("Failure during cleanup", e2);
    }
    throw e;
  }
}

代码示例来源:origin: io.dropwizard/dropwizard-core

protected Server buildServer(LifecycleEnvironment lifecycle,
               ThreadPool threadPool) {
  final Server server = new Server(threadPool);
  server.addLifeCycleListener(buildSetUIDListener());
  lifecycle.attach(server);
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setServer(server);
  errorHandler.setShowStacks(false);
  server.addBean(errorHandler);
  server.setStopAtShutdown(true);
  server.setStopTimeout(shutdownGracePeriod.toMilliseconds());
  return server;
}

代码示例来源:origin: cd.connect.common/connect-runnable-war

protected void attachServerLifecycleListeners() {
  // check to see if there are any other interested parties and attach them to the server
  // lifecycle if so
  for(WarLifecycleListener lifecycleListener : ServiceLoader.load(WarLifecycleListener.class)) {
    final WarLifecycleListener listener = lifecycleListener;
    server.addLifeCycleListener(new LifeCycle.Listener() {
      @Override
      public void lifeCycleStarting(LifeCycle event) {
        listener.lifeCycleStarting(server, context);
      }
      @Override
      public void lifeCycleStarted(LifeCycle event) {
        lifecycleListener.lifeCycleStarted(server, context);
      }
      @Override
      public void lifeCycleFailure(LifeCycle event, Throwable cause) {
        lifecycleListener.lifeCycleFailure(server, cause, context);
      }
      @Override
      public void lifeCycleStopping(LifeCycle event) {
        lifecycleListener.lifeCycleStopping(server, context);
      }
      @Override
      public void lifeCycleStopped(LifeCycle event) {
        lifecycleListener.lifeCycleStopped(server, context);
      }
    });
  }
}

代码示例来源:origin: org.avaje.glue/jetty-runner

protected void attachServerLifecycleListeners() {
 for (ContainerLifecycleListener lifecycleListener : ServiceLoader.load(ContainerLifecycleListener.class)) {
  server.addLifeCycleListener(new JettyLifecyleAdapter(lifecycleListener));
 }
}

代码示例来源:origin: stackoverflow.com

final Server server = configuration.getServerFactory().build(environment);
try {
  server.addLifeCycleListener(new LifeCycleListener());
  cleanupAsynchronously();
  server.start();

代码示例来源:origin: mesosphere/dcos-commons

throw new IllegalStateException("Already started");
server.addLifeCycleListener(listener);

代码示例来源:origin: addthis/hydra

private Server createServer(final Spawn spawn, SpawnServiceConfiguration configuration) throws Exception {
  Server server = new Server();
  initServerConnectors(server, spawn, configuration);
  // for closing certain api resource, namely JobsResource, but new ones can be added
  final Closer closer = Closer.create();
  ServletContextHandler context = createServletContextHandler(spawn, configuration, closer);
  Handler handler = createRootHandler(context);
  server.setAttribute("org.eclipse.jetty.Request.maxFormContentSize", 5000000);
  server.setHandler(handler);
  // this must be after server.setHandler(handler) because websocket configuration needs
  // the server object from servletContextHandler
  configureWebSocketServlet(context);
  server.addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() {
    @Override
    public void lifeCycleStopping(LifeCycle event) {
      super.lifeCycleStopping(event);
      try {
        closer.close();
      } catch (IOException ex) {
        log.error("IOException while closing jetty resources: ", ex);
      }
    }
  });
  return server;
}

代码示例来源:origin: stackoverflow.com

protected Server buildServer(LifecycleEnvironment lifecycle,
                ThreadPool threadPool) {
   final Server server = new Server(threadPool);
   server.addLifeCycleListener(buildSetUIDListener());
   lifecycle.attach(server);
   final ErrorHandler errorHandler = new ErrorHandler();
   errorHandler.setServer(server);
   errorHandler.setShowStacks(false);
   server.addBean(errorHandler);
   server.setStopAtShutdown(true);
   server.setStopTimeout(shutdownGracePeriod.toMilliseconds());
   return server;
 }

代码示例来源:origin: apache/felix

this.server = new Server();
this.server.addLifeCycleListener(this);

代码示例来源:origin: org.apache.druid/druid-server

server.setStopTimeout(gracefulStop);
server.addLifeCycleListener(new LifeCycle.Listener()

相关文章