当前位置: 首页>>代码示例>>Java>>正文


Java TomcatEmbeddedServletContainerFactory.addContextValves方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:CasEmbeddedContainerTomcatConfiguration.java

示例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);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:CasEmbeddedContainerTomcatConfiguration.java

示例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);
	}
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:23,代码来源:ServerProperties.java

示例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);
    }
}
 
开发者ID:ruyangit,项目名称:angit,代码行数:13,代码来源:ContainerAccessLogCustomizer.java

示例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);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:9,代码来源:ServerProperties.java


注:本文中的org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.addContextValves方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。