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

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

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

Tomcat.getEngine介绍

[英]Access to the engine, for further customization.
[中]访问引擎,以便进一步定制。

代码示例

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

@Override
  public String hostName() {
    if (hostName != null) {
      return hostName;
    }

    // If connector w/o hostName
    return tomcat.map(t -> t.getEngine().getDefaultHost())
           .orElse(null);
  }
}

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

private void addInstanceIdToEngineName() {
  int instanceId = containerCounter.incrementAndGet();
  if (instanceId > 0) {
    Engine engine = this.tomcat.getEngine();
    engine.setName(engine.getName() + "-" + instanceId);
  }
}

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

@Test
public void verifySingleConnector() {
  // Relevant to Tomcat 9.0
  assertThat(applicationContext).isInstanceOf(WebServerApplicationContext.class);
  WebServer webServer = ((WebServerApplicationContext) applicationContext).getWebServer();
  assertThat(webServer).isInstanceOf(TomcatWebServer.class);
  assertThat(((TomcatWebServer) webServer).getTomcat()
                      .getEngine()
                      .getService()
                      .findConnectors()).hasSize(1);
}

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

@Override
public WebServer getWebServer(HttpHandler httpHandler) {
  Tomcat tomcat = new Tomcat();
  File baseDir = (this.baseDirectory != null) ? this.baseDirectory
      : createTempDir("tomcat");
  tomcat.setBaseDir(baseDir.getAbsolutePath());
  Connector connector = new Connector(this.protocol);
  tomcat.getService().addConnector(connector);
  customizeConnector(connector);
  tomcat.setConnector(connector);
  tomcat.getHost().setAutoDeploy(false);
  configureEngine(tomcat.getEngine());
  TomcatHttpHandlerAdapter servlet = new TomcatHttpHandlerAdapter(httpHandler);
  prepareContext(tomcat.getHost(), servlet);
  return new TomcatWebServer(tomcat, getPort() >= 0);
}

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

@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
  Tomcat tomcat = new Tomcat();
  File baseDir = (this.baseDirectory != null) ? this.baseDirectory
      : createTempDir("tomcat");
  tomcat.setBaseDir(baseDir.getAbsolutePath());
  Connector connector = new Connector(this.protocol);
  tomcat.getService().addConnector(connector);
  customizeConnector(connector);
  tomcat.setConnector(connector);
  tomcat.getHost().setAutoDeploy(false);
  configureEngine(tomcat.getEngine());
  for (Connector additionalConnector : this.additionalTomcatConnectors) {
    tomcat.getService().addConnector(additionalConnector);
  }
  prepareContext(tomcat.getHost(), initializers);
  return getTomcatWebServer(tomcat);
}

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

public void setDefaultHost(String defaultHostName) {
  tomcat.setHostname(defaultHostName);
  tomcat.getEngine().setDefaultHost(defaultHostName);
}

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

public Host getHost() {
  Engine engine = getEngine();
  if (engine.findChildren().length > 0) {
    return (Host) engine.findChildren()[0];
  }
  Host host = new StandardHost();
  host.setName(hostname);
  getEngine().addChild(host);
  return host;
}

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

/**
 * Sets the current host - all future webapps will
 * be added to this host. When tomcat starts, the
 * host will be the default host.
 *
 * @param host The current host
 */
public void setHost(Host host) {
  Engine engine = getEngine();
  boolean found = false;
  for (Container engineHost : engine.findChildren()) {
    if (engineHost == host) {
      found = true;
    }
  }
  if (!found) {
    engine.addChild(host);
  }
}

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

public Host getHost() {
  Engine engine = getEngine();
  if (engine.findChildren().length > 0) {
    return (Host) engine.findChildren()[0];
  }
  Host host = new StandardHost();
  host.setName(hostname);
  getEngine().addChild(host);
  return host;
}

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

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

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

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

代码示例来源:origin: apache/ofbiz-framework

private Engine prepareTomcatEngine(Tomcat tomcat, Property engineConfig) {
  Engine engine = tomcat.getEngine();
  engine.setName(engineConfig.name);
  // set the JVM Route property (JK/JK2)
  String jvmRoute = ContainerConfig.getPropertyValue(engineConfig, "jvm-route", null);
  if (jvmRoute != null) {
    engine.setJvmRoute(jvmRoute);
  }
  return engine;
}

代码示例来源:origin: apache/ofbiz-framework

private Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts) {
  // assume that the first virtual-host will be the default; additional virtual-hosts will be aliases
  String hostName = virtualHosts.get(0);
  Host host;
  Engine engine = tomcat.getEngine();
  org.apache.catalina.Container childContainer = engine.findChild(hostName);
  if (childContainer instanceof Host) {
    host = (Host) childContainer;
  } else {
    host = new StandardHost();
    host.setName(hostName);
    engine.addChild(host);
  }
  virtualHosts.stream()
    .filter(virtualHost -> virtualHost != hostName)
    .forEach(virtualHost -> host.addAlias(virtualHost));
  return host;
}

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

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public Host getHost() {
  if (host == null) {
    host = new StandardHost();
    host.setName(hostname);
    getEngine().addChild( host );
  }
  return host;
}

代码示例来源:origin: com.oath.microservices/micro-tomcat

public void run(CompletableFuture start,  JaxRsServletConfigurer jaxRsConfigurer, CompletableFuture end) {
  Tomcat tomcat = new Tomcat();
  tomcat.setPort(serverData.getPort());
  tomcat.getHost().setAutoDeploy(false);
  tomcat.getEngine().setBackgroundProcessorDelay(-1);
   File docBase = new File(".");
   StandardContext context =(StandardContext)tomcat.addContext("", docBase.getAbsolutePath());
  context.addServletContainerInitializer(new TomcatListener(jaxRsConfigurer, serverData, filterData, servletData, servletContextListenerData, servletRequestListenerData),
      new HashSet<>());
  addAccessLog(tomcat,context);
  serverData.getModule().getServerConfigManager().accept(new WebServerProvider(tomcat));
  addSSL(tomcat.getConnector());
  startServer(tomcat, start, end);
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.url.mapper.clustermessage

public static Host addHostToEngine(String hostName) {
  String hostBaseDir = CarbonUtils.getCarbonRepository() + "/webapps/";
  CarbonTomcatService carbonTomcatService = DataHolder.getInstance().getCarbonTomcatService();
  // adding virtual host to tomcat engine
  Engine engine = carbonTomcatService.getTomcat().getEngine();
  StandardHost host = new StandardHost();
  host.setAppBase(hostBaseDir);
  host.setName(hostName);
  host.setUnpackWARs(false);
  host.addValve(new CarbonContextCreatorValve());
  host.addValve(new CompositeValve());
  engine.addChild(host);
  log.info("host added to the tomcat: " + host);
  return host;
}

相关文章