本文整理匯總了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);
}