本文整理了Java中org.apache.catalina.startup.Tomcat.getHost()
方法的一些代码示例,展示了Tomcat.getHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tomcat.getHost()
方法的具体详情如下:
包路径:org.apache.catalina.startup.Tomcat
类名称:Tomcat
方法名:getHost
暂无
代码示例来源:origin: org.springframework.boot/spring-boot
private Context findContext() {
for (Container child : this.tomcat.getHost().findChildren()) {
if (child instanceof Context) {
return (Context) child;
}
}
throw new IllegalStateException("The host does not contain a Context");
}
代码示例来源:origin: org.springframework.boot/spring-boot
private String getContextPath() {
return Arrays.stream(this.tomcat.getHost().findChildren())
.filter(TomcatEmbeddedContext.class::isInstance)
.map(TomcatEmbeddedContext.class::cast)
.map(TomcatEmbeddedContext::getPath).collect(Collectors.joining(" "));
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void undeployConfig() {
if (this.context != null) {
this.context.removeServletMapping("/");
this.tomcatServer.getHost().removeChild(this.context);
}
}
代码示例来源:origin: org.springframework.boot/spring-boot
private void performDeferredLoadOnStartup() {
try {
for (Container child : this.tomcat.getHost().findChildren()) {
if (child instanceof TomcatEmbeddedContext) {
((TomcatEmbeddedContext) child).deferredLoadOnStartup();
}
}
}
catch (Exception ex) {
if (ex instanceof WebServerException) {
throw (WebServerException) ex;
}
throw new WebServerException("Unable to start embedded Tomcat connectors",
ex);
}
}
代码示例来源:origin: SonarSource/sonarqube
void start() {
// '%2F' (slash /) and '%5C' (backslash \) are permitted as path delimiters in URLs
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
System.setProperty("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true");
tomcat = new Tomcat();
// Initialize directories
String basedir = tomcatBasedir().getAbsolutePath();
tomcat.setBaseDir(basedir);
tomcat.getHost().setAppBase(basedir);
tomcat.getHost().setAutoDeploy(false);
tomcat.getHost().setCreateDirs(false);
tomcat.getHost().setDeployOnStartup(true);
new TomcatAccessLog().configure(tomcat, props);
TomcatConnectors.configure(tomcat, props);
webappContext = new TomcatContexts().configure(tomcat, props);
try {
tomcat.start();
new TomcatStartupLogs(Loggers.get(getClass())).log(tomcat);
} catch (LifecycleException e) {
Loggers.get(EmbeddedTomcat.class).error("Fail to start web server", e);
Throwables.propagate(e);
}
}
代码示例来源: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: org.springframework.boot/spring-boot
private void rethrowDeferredStartupExceptions() throws Exception {
Container[] children = this.tomcat.getHost().findChildren();
for (Container container : children) {
if (container instanceof TomcatEmbeddedContext) {
TomcatStarter tomcatStarter = ((TomcatEmbeddedContext) container)
.getStarter();
if (tomcatStarter != null) {
Exception exception = tomcatStarter.getStartUpException();
if (exception != null) {
throw exception;
}
}
}
if (!LifecycleState.STARTED.equals(container.getState())) {
throw new IllegalStateException(container + " failed to start");
}
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void enable_access_logs_by_Default() throws Exception {
Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS);
Props props = new Props(new Properties());
props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath());
underTest.configure(tomcat, props);
verify(tomcat.getHost().getPipeline()).addValve(any(ProgrammaticLogbackValve.class));
}
代码示例来源: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: SonarSource/sonarqube
private static void configureLogbackAccess(Tomcat tomcat, Props props) {
if (props.valueAsBoolean(PROPERTY_ENABLE, true)) {
ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve();
LogbackHelper helper = new LogbackHelper();
LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access");
FileAppender appender = policy.createAppender("ACCESS_LOG");
PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder();
fileEncoder.setContext(valve);
fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN));
fileEncoder.start();
appender.setEncoder(fileEncoder);
appender.start();
valve.addAppender(appender);
tomcat.getHost().getPipeline().addValve(valve);
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
private Optional<Context> findContext() {
return Stream.of(this.webServer.getTomcat().getHost().findChildren())
.filter(Context.class::isInstance).map(Context.class::cast)
.findFirst();
}
代码示例来源:origin: org.springframework.boot/spring-boot-actuator
private Context findContext(TomcatWebServer tomcatWebServer) {
for (Container container : tomcatWebServer.getTomcat().getHost().findChildren()) {
if (container instanceof Context) {
return (Context) container;
}
}
return null;
}
代码示例来源:origin: camunda/camunda-bpm-platform
tomcat.setBaseDir(getWorkingDir());
tomcat.getHost().setAppBase(getWorkingDir());
tomcat.getHost().setAutoDeploy(true);
tomcat.getHost().setDeployOnStartup(true);
tomcat.addWebapp(tomcat.getHost(), contextPath, webAppPath);
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/**
* Add a webapp using normal WEB-INF/web.xml if found.
*
* @param contextPath
* @param baseDir
* @return new Context
* @throws ServletException
*/
public Context addWebapp(String contextPath,
String baseDir) throws ServletException {
return addWebapp(getHost(), contextPath, baseDir);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
private void silence(String ctx) {
String base = "org.apache.catalina.core.ContainerBase.[default].[";
base += getHost().getName();
base += "].[";
base += ctx;
base += "]";
Logger.getLogger(base).setLevel(Level.WARNING);
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
/**
* Add a webapp using normal WEB-INF/web.xml if found.
*
* @param contextPath
* @param baseDir
* @return new Context
* @throws ServletException
*/
public Context addWebapp(String contextPath,
String baseDir) throws ServletException {
return addWebapp(getHost(), contextPath, baseDir);
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
private void silence(String ctx) {
String base = "org.apache.catalina.core.ContainerBase.[default].[";
base += getHost().getName();
base += "].[";
base += ctx;
base += "]";
Logger.getLogger(base).setLevel(Level.WARNING);
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
private URL getWebappConfigFileFromDirectory(File docBase, String contextName) {
URL result = null;
File webAppContextXml = new File(docBase, Constants.ApplicationContextXml);
if (webAppContextXml.exists()) {
try {
result = webAppContextXml.toURI().toURL();
} catch (MalformedURLException e) {
Logger.getLogger(getLoggerName(getHost(), contextName)).log(Level.WARNING,
sm.getString("tomcat.noContextXml", docBase), e);
}
}
return result;
}
代码示例来源:origin: org.dbflute.tomcat/tomcat-boot
protected void disableUnpackWARsOption() {
final Host host = server.getHost();
if (host instanceof StandardHost) {
info("...Disabling unpackWARs");
((StandardHost) host).setUnpackWARs(false);
}
}
内容来源于网络,如有侵权,请联系作者删除!