org.apache.catalina.Server.getState()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(121)

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

Server.getState介绍

暂无

代码示例

代码示例来源:origin: line/armeria

static TomcatService forConfig(TomcatServiceConfig config) {
  final Consumer<Connector> postStopTask = connector -> {
    final org.apache.catalina.Server server = connector.getService().getServer();
    if (server.getState() == LifecycleState.STOPPED) {
      try {
        logger.info("Destroying an embedded Tomcat: {}", toString(server));
        server.destroy();
      } catch (Exception e) {
        logger.warn("Failed to destroy an embedded Tomcat: {}", toString(server), e);
      }
    }
  };
  return new ManagedTomcatService(null, new ManagedConnectorFactory(config), postStopTask);
}

代码示例来源:origin: line/armeria

void start() throws Exception {
  assert hostName() != null;
  started = false;
  connector = connectorFactory.apply(hostName());
  final Service service = connector.getService();
  final Engine engine = TomcatUtil.engine(service, hostName());
  final String engineName = engine.getName();
  if (activeEngines.contains(engineName)) {
    throw new TomcatServiceException("duplicate engine name: " + engineName);
  }
  server = service.getServer();
  if (!TOMCAT_START_STATES.contains(server.getState())) {
    logger.info("Starting an embedded Tomcat: {}", toString(server));
    server.start();
    started = true;
  } else {
    throw new TomcatServiceException("Cannot manage already running server: " + engineName);
  }
  activeEngines.add(engineName);
  this.engineName = engineName;
}

代码示例来源:origin: SonarSource/sonarqube

void terminate() {
 if (tomcat.getServer().getState().isAvailable()) {
  try {
   tomcat.stop();
   tomcat.destroy();
  } catch (Exception e) {
   Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e);
  }
 }
 deleteQuietly(tomcatBasedir());
}

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/tomcat

private void destroy(Tomcat tomcat) throws LifecycleException, InterruptedException {
  tomcat.destroy();
  
  long deadline = System.currentTimeMillis() + 10000;
  do {
    switch(tomcat.getServer().getState()) {
    case DESTROYED:
    case FAILED:
      return;
    default : {
    }
    }
    Thread.sleep(10);
  } while(deadline > System.currentTimeMillis());		
}

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/tomcat

private void stop(Tomcat tomcat) throws LifecycleException, InterruptedException {
  tomcat.stop();
  
  long deadline = System.currentTimeMillis() + 10000;
  do {
    switch(tomcat.getServer().getState()) {
    case STOPPED:
    case DESTROYING:
    case DESTROYED:
    case FAILED:
      return;
    default : {
    }
    }
    Thread.sleep(10);
  } while(deadline > System.currentTimeMillis());		
}

代码示例来源:origin: com.github.bordertech.lde/lde-tomcat

/**
 * Wait for TOMCAT to stop.
 *
 * @throws LifecycleException life cycle exception occurred
 */
protected void waitForTomcatToStop() throws LifecycleException {
  int i = 0;
  while (tomcat.getServer().getState() != LifecycleState.STOPPED) {
    waitInterval();
    if (i++ > 10) {
      throw new IllegalStateException("Timeout waiting for TOMCAT to stop");
    }
  }
}

代码示例来源:origin: com.github.skjolber.mockito-rest-spring/tomcat

private void start(Tomcat tomcat) throws InterruptedException, LifecycleException {
  tomcat.start();
  long deadline = System.currentTimeMillis() + 10000;
  do {
    switch(tomcat.getServer().getState()) {
    case NEW:
    case INITIALIZING:
    case INITIALIZED:
    case STARTING_PREP:
    case STARTING:
      Thread.sleep(10);
      continue;
    default : break;
    }
    break;
  } while(deadline > System.currentTimeMillis());
}

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

public void shutdown() throws Throwable {
     if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
      if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
        tomcat.stop();
      }
      tomcat.destroy();
    }
  }
}

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

public void shutdown() throws Throwable {
    if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) {
      if (tomcat.getServer().getState() != LifecycleState.STOPPED) {
        tomcat.stop();
      }
      tomcat.destroy();
    }
  }
}

代码示例来源:origin: com.github.bordertech.lde/lde-tomcat

/**
 * Wait for TOMCAT to start.
 *
 * @throws LifecycleException life cycle exception occurred
 */
protected void waitForTomcatToStart() throws LifecycleException {
  int i = 0;
  while (tomcat.getServer().getState() != LifecycleState.STARTED) {
    waitInterval();
    if (i++ > 10) {
      tomcat.stop();
      throw new IllegalStateException("Timeout waiting for TOMCAT to start");
    }
  }
}

代码示例来源:origin: com.att.nsa/nsaServerLibrary

private void waitForTomcatLifecycleState(LifecycleState s) throws InterruptedException {
  final Object mutex = new Object();
  final LifecycleState state = s;
  
  tomcat.getServer().addLifecycleListener(new LifecycleListener() {
    @Override
    public void lifecycleEvent(LifecycleEvent event) {
      if (event.getLifecycle().getState() == state) {
        synchronized (mutex) {
          tomcat.getServer().removeLifecycleListener(this);
          mutex.notify();
        }
      }
    }
  });
  synchronized (mutex) {
    while (tomcat.getServer().getState() != state)
      mutex.wait();
  }
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

/**
 * Process a "destroy" event for this Context.
 */
protected synchronized void destroy() {
  // Called from StandardContext.destroy()
  if (log.isDebugEnabled())
    log.debug(sm.getString("contextConfig.destroy"));
  // Skip clearing the work directory if Tomcat is being shutdown
  Server s = getServer();
  if (s != null && !s.getState().isAvailable()) {
    return;
  }
  
  // Changed to getWorkPath per Bugzilla 35819.
  String workDir = ((StandardContext) context).getWorkPath();
  if (workDir != null)
    ExpandWar.delete(new File(workDir));
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Process a "destroy" event for this Context.
 */
protected synchronized void destroy() {
  // Called from StandardContext.destroy()
  if (log.isDebugEnabled()) {
    log.debug(sm.getString("contextConfig.destroy"));
  }
  // Skip clearing the work directory if Tomcat is being shutdown
  Server s = getServer();
  if (s != null && !s.getState().isAvailable()) {
    return;
  }
  // Changed to getWorkPath per Bugzilla 35819.
  if (context instanceof StandardContext) {
    String workDir = ((StandardContext) context).getWorkPath();
    if (workDir != null) {
      ExpandWar.delete(new File(workDir));
    }
  }
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

LifecycleState state = s.getState();
if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0
    && LifecycleState.DESTROYED.compareTo(state) >= 0) {

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Process a "destroy" event for this Context.
 */
protected synchronized void destroy() {
  // Called from StandardContext.destroy()
  if (log.isDebugEnabled()) {
    log.debug(sm.getString("contextConfig.destroy"));
  }
  // Skip clearing the work directory if Tomcat is being shutdown
  Server s = getServer();
  if (s != null && !s.getState().isAvailable()) {
    return;
  }
  // Changed to getWorkPath per Bugzilla 35819.
  if (context instanceof StandardContext) {
    String workDir = ((StandardContext) context).getWorkPath();
    if (workDir != null) {
      ExpandWar.delete(new File(workDir));
    }
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Process a "destroy" event for this Context.
 */
protected synchronized void destroy() {
  // Called from StandardContext.destroy()
  if (log.isDebugEnabled()) {
    log.debug(sm.getString("contextConfig.destroy"));
  }
  // Skip clearing the work directory if Tomcat is being shutdown
  Server s = getServer();
  if (s != null && !s.getState().isAvailable()) {
    return;
  }
  // Changed to getWorkPath per Bugzilla 35819.
  if (context instanceof StandardContext) {
    String workDir = ((StandardContext) context).getWorkPath();
    if (workDir != null) {
      ExpandWar.delete(new File(workDir));
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

LifecycleState state = s.getState();
if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0
    && LifecycleState.DESTROYED.compareTo(state) >= 0) {

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

/**
 * Process a "destroy" event for this Context.
 */
protected synchronized void destroy() {
  // Called from StandardContext.destroy()
  if (log.isDebugEnabled())
    log.debug(sm.getString("contextConfig.destroy"));
  // Skip clearing the work directory if Tomcat is being shutdown
  Server s = getServer();
  if (s != null && !s.getState().isAvailable()) {
    return;
  }
  // Changed to getWorkPath per Bugzilla 35819.
  if (context instanceof StandardContext) {
    String workDir = ((StandardContext) context).getWorkPath();
    if (workDir != null) {
      ExpandWar.delete(new File(workDir));
    }
  }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

void terminate() {
 if (tomcat.getServer().getState().isAvailable()) {
  try {
   tomcat.stop();
   tomcat.destroy();
  } catch (Exception e) {
   Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e);
  }
 }
 deleteQuietly(tomcatBasedir());
}

代码示例来源:origin: org.apache.tomee.patch/commons-jcs-jcache-extras

private void stop(final Tomcat tomcat) throws LifecycleException {
  if (LifecycleState.STARTED.equals(tomcat.getServer().getState())) {
    tomcat.stop();
    tomcat.destroy();
  }
}

相关文章