本文整理汇总了Java中org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.addContextValves方法的典型用法代码示例。如果您正苦于以下问题:Java TomcatEmbeddedServletContainerFactory.addContextValves方法的具体用法?Java TomcatEmbeddedServletContainerFactory.addContextValves怎么用?Java TomcatEmbeddedServletContainerFactory.addContextValves使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
的用法示例。
在下文中一共展示了TomcatEmbeddedServletContainerFactory.addContextValves方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureRewriteValve
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入方法依赖的package包/类
private void configureRewriteValve(final TomcatEmbeddedServletContainerFactory tomcat) {
final Resource res = casProperties.getServer().getRewriteValveConfigLocation();
if (ResourceUtils.doesResourceExist(res)) {
final RewriteValve valve = new RewriteValve() {
@Override
protected synchronized void startInternal() throws LifecycleException {
super.startInternal();
try (InputStream is = res.getInputStream();
InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
BufferedReader buffer = new BufferedReader(isr)) {
parse(buffer);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
};
valve.setAsyncSupported(true);
valve.setEnabled(true);
LOGGER.debug("Creating Rewrite valve configuration for the embedded tomcat container...");
tomcat.addContextValves(valve);
}
}
示例2: configureExtendedAccessLogValve
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入方法依赖的package包/类
private void configureExtendedAccessLogValve(final TomcatEmbeddedServletContainerFactory tomcat) {
final CasServerProperties.ExtendedAccessLog ext = casProperties.getServer().getExtAccessLog();
if (ext.isEnabled() && StringUtils.isNotBlank(ext.getPattern())) {
LOGGER.debug("Creating extended access log valve configuration for the embedded tomcat container...");
final ExtendedAccessLogValve valve = new ExtendedAccessLogValve();
valve.setPattern(ext.getPattern());
if (StringUtils.isBlank(ext.getDirectory())) {
valve.setDirectory(serverProperties.getTomcat().getAccesslog().getDirectory());
} else {
valve.setDirectory(ext.getDirectory());
}
valve.setPrefix(ext.getPrefix());
valve.setSuffix(ext.getSuffix());
valve.setAsyncSupported(true);
valve.setEnabled(true);
valve.setRotatable(true);
valve.setBuffered(true);
tomcat.addContextValves(valve);
tomcat.addEngineValves(valve);
}
}
示例3: customizeRemoteIpValve
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入方法依赖的package包/类
private void customizeRemoteIpValve(ServerProperties properties,
TomcatEmbeddedServletContainerFactory factory) {
String protocolHeader = getProtocolHeader();
String remoteIpHeader = getRemoteIpHeader();
// For back compatibility the valve is also enabled if protocol-header is set
if (StringUtils.hasText(protocolHeader) || StringUtils.hasText(remoteIpHeader)
|| properties.getOrDeduceUseForwardHeaders()) {
RemoteIpValve valve = new RemoteIpValve();
valve.setProtocolHeader(StringUtils.hasLength(protocolHeader)
? protocolHeader : "X-Forwarded-Proto");
if (StringUtils.hasLength(remoteIpHeader)) {
valve.setRemoteIpHeader(remoteIpHeader);
}
// The internal proxies default to a white list of "safe" internal IP
// addresses
valve.setInternalProxies(getInternalProxies());
valve.setPortHeader(getPortHeader());
valve.setProtocolHeaderHttpsValue(getProtocolHeaderHttpsValue());
// ... so it's safe to add this valve by default.
factory.addContextValves(valve);
}
}
示例4: customize
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入方法依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) container;
//访问日志设置
LogbackValve logbackValve = new LogbackValve();
logbackValve.setQuiet(true);
logbackValve.setFilename(logbackAccessFile);
containerFactory.addContextValves(logbackValve);
}
}
示例5: customizeAccessLog
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入方法依赖的package包/类
private void customizeAccessLog(TomcatEmbeddedServletContainerFactory factory) {
AccessLogValve valve = new AccessLogValve();
valve.setPattern(this.accesslog.getPattern());
valve.setDirectory(this.accesslog.getDirectory());
valve.setPrefix(this.accesslog.getPrefix());
valve.setSuffix(this.accesslog.getSuffix());
factory.addContextValves(valve);
}