org.apache.catalina.startup.Tomcat.getServer()方法的使用及代码示例

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

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

Tomcat.getServer介绍

[英]Get the server object. You can add listeners and few more customizations. JNDI is disabled by default.
[中]获取服务器对象。您可以添加侦听器和一些其他自定义设置。默认情况下禁用JNDI。

代码示例

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

void awaitTermination() {
  tomcat.getServer().await();
 }
}

代码示例来源:origin: OryxProject/oryx

/**
 * Blocks and waits until the server shuts down.
 */
public void await() {
 Server server;
 synchronized (this) {
  server = tomcat.getServer();
 }
 server.await(); // Can't do this with lock held
}

代码示例来源:origin: org.springframework.boot/spring-boot

@Override
public void run() {
  TomcatWebServer.this.tomcat.getServer().await();
}

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

String webappDirLocation = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);

StandardContext ctx = (StandardContext) tomcat.addWebapp("/embeddedTomcat",
        new File(webappDirLocation).getAbsolutePath());

//declare an alternate location for your "WEB-INF/classes" dir:     
File additionWebInfClasses = new File("target/classes");
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
ctx.setResources(resources);

tomcat.start();
tomcat.getServer().await();

代码示例来源:origin: org.springframework.boot/spring-boot

private void addPreviouslyRemovedConnectors() {
  Service[] services = this.tomcat.getServer().findServices();
  for (Service service : services) {
    Connector[] connectors = this.serviceConnectors.get(service);
    if (connectors != null) {
      for (Connector connector : connectors) {
        service.addConnector(connector);
        if (!this.autoStart) {
          stopProtocolHandler(connector);
        }
      }
      this.serviceConnectors.remove(service);
    }
  }
}

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

String webappDirLocation = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);

StandardContext ctx = (StandardContext) tomcat.addWebapp("/embeddedTomcat",
        new File(webappDirLocation).getAbsolutePath());

//declare an alternate location for your "WEB-INF/classes" dir:     
File additionWebInfClasses = new File("target/classes");
VirtualDirContext resources = new VirtualDirContext();
resources.setExtraResourcePaths("/WEB-INF/classes=" + additionWebInfClasses);
ctx.setResources(resources);

tomcat.start();
tomcat.getServer().await();

代码示例来源:origin: org.springframework.boot/spring-boot

private void removeServiceConnectors() {
  for (Service service : this.tomcat.getServer().findServices()) {
    Connector[] connectors = service.findConnectors().clone();
    this.serviceConnectors.put(service, connectors);
    for (Connector connector : connectors) {
      service.removeConnector(connector);
    }
  }
}

代码示例来源:origin: OryxProject/oryx

public synchronized void start() throws IOException {
 if (id != null) {
  log.info("Starting Serving Layer {}", id);
 }
 Preconditions.checkState(tomcat == null);
 // Has to happen very early before Tomcat init:
 System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
 noSuchBaseDir = Files.createTempDirectory("Oryx");
 noSuchBaseDir.toFile().deleteOnExit();
 Tomcat tomcat = new Tomcat();
 Connector connector = makeConnector();
 configureTomcat(tomcat, connector);
 configureEngine(tomcat.getEngine());
 configureServer(tomcat.getServer());
 configureHost(tomcat.getHost());
 makeContext(tomcat, noSuchBaseDir);
 try {
  tomcat.start();
 } catch (LifecycleException le) {
  throw new IOException(le);
 }
 this.tomcat = tomcat;
}

代码示例来源: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: pippo-java/pippo

tomcat.getServer().await();

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

/**
 * Start the server.
 *
 * @throws LifecycleException Start error
 */
public void start() throws LifecycleException {
  getServer();
  server.start();
}

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

/**
 * Stop the server.
 *
 * @throws LifecycleException Stop error
 */
public void stop() throws LifecycleException {
  getServer();
  server.stop();
}

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

/**
 * Get the service object. Can be used to add more
 * connectors and few other global settings.
 * @return The service
 */
public Service getService() {
  return getServer().findServices()[0];
}

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

/**
 * Destroy the server. This object cannot be used once this method has been
 * called.
 *
 * @throws LifecycleException Destroy error
 */
public void destroy() throws LifecycleException {
  getServer();
  server.destroy();
  // Could null out objects here
}

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

/**
 * Initialize the server.
 *
 * @throws LifecycleException Init error
 */
public void init() throws LifecycleException {
  getServer();
  server.init();
}

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

/**
 * Stop the server.
 *
 * @throws LifecycleException
 */
public void stop() throws LifecycleException {
  getServer();
  server.stop();
}

代码示例来源:origin: nutzam/nutzboot

@Override
  public void run() {
    TomcatStarter.this.tomcat.getServer().await();
  }
};

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

/**
 * Initialize the server.
 *
 * @throws LifecycleException Init error
 */
public void init() throws LifecycleException {
  getServer();
  server.init();
}

代码示例来源: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: stackoverflow.com

public static void main(String[] args) throws Exception {
  Tomcat tomcat = new Tomcat();
  tomcat.setPort(8080);

  //actually deploy stuff on your tomcat by defining contexts          

  tomcat.start();
  tomcat.getServer().await();
}

相关文章