Java TomcatContextCustomizer类代码示例
本文整理汇总了Java中org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer类的典型用法代码示例。如果您正苦于以下问题:Java TomcatContextCustomizer类的具体用法?Java TomcatContextCustomizer怎么用?Java TomcatContextCustomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
本文整理汇总了Java中org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer类的典型用法代码示例。如果您正苦于以下问题:Java TomcatContextCustomizer类的具体用法?Java TomcatContextCustomizer怎么用?Java TomcatContextCustomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TomcatContextCustomizer类属于org.springframework.boot.context.embedded.tomcat包,在下文中一共展示了TomcatContextCustomizer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: cookieProcessorCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container;
factory.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
context.setCookieProcessor(new LegacyCookieProcessor());
}
});
}
}
};
}
示例2: redirectContextRootCanBeConfigured
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Test
public void redirectContextRootCanBeConfigured() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.redirect-context-root", "false");
bindProperties(map);
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false);
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container);
Context context = mock(Context.class);
for (TomcatContextCustomizer customizer : container
.getTomcatContextCustomizers()) {
customizer.customize(context);
}
verify(context).setMapperContextRootRedirectEnabled(false);
}
示例3: customizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer customizer() {
return new EmbeddedServletContainerCustomizer() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(ConfigurableEmbeddedServletContainer container)</span> </span>{
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
<span class="highlight">TomcatContextCustomizer</span> contextCustomizer = <span class="hljs-keyword">new</span> <span class="highlight">TomcatContextCustomizer</span>() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(Context context)</span> </span>{
context.setCookieProcessor(<span class="hljs-keyword">new</span> LegacyCookieProcessor());
}
};
tomcat.addContextCustomizers(contextCustomizer);
}
};
}
示例4: servletContainer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
MockService config = MockService.getInstance();
factory.setPort(config.getPort());
factory.setSessionTimeout(10, TimeUnit.MINUTES);
factory.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
JarScanner jarScanner = new JarScanner() {
@Override
public void scan(ServletContext arg0, ClassLoader arg1,
JarScannerCallback arg2, Set<String> arg3) {
}
};
context.setJarScanner(jarScanner);
}
});
return factory;
}
示例5: containerCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
if (highAvailability) {
logger.info("Setting up high availability configuration");
return factory -> {
logger.info("Customizing Tomcat container");
TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) factory;
<span class="highlight">TomcatContextCustomizer</span> tomcatContextCustomizer = context -> {
context.setSessionTimeout(<span class="hljs-number">30</span>);
context.setManager(<span class="hljs-keyword">new</span> MemcachedBackupSessionManager() {{
setMemcachedNodes(nodes);
setFailoverNodes(failover);
setRequestUriIgnorePattern(<span class="hljs-string">".*\\.(ico|png|gif|jpg|css|js)$"</span>);
}});
};
containerFactory.setTomcatContextCustomizers(Collections.singletonList(tomcatContextCustomizer));
setMimeMappings(factory);
};
} <span class="hljs-keyword">else</span> {
logger.info(<span class="hljs-string">"Skipping HA configuration"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>::setMimeMappings;
}
}
示例6: tomcatContextCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public TomcatContextCustomizer tomcatContextCustomizer() {
return new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
context.addServletContainerInitializer(new WsSci(), null);
}
};
}
示例7: configure
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
public static void configure(TomcatEmbeddedServletContainerFactory tomcatFactory) {
tomcatFactory.addContextCustomizers((<span class="highlight">TomcatContextCustomizer</span>) context -> {
<span class="hljs-keyword">boolean</span> development = (System.getProperty(<span class="hljs-string">"airsonic.development"</span>) != <span class="hljs-keyword">null</span>);
<span class="hljs-comment">// Increase the size and time before eviction of the Tomcat</span>
<span class="hljs-comment">// cache so that resources aren't uncompressed too often.</span>
<span class="hljs-comment">// See https://github.com/jhipster/generator-jhipster/issues/3995</span>
StandardRoot resources = <span class="hljs-keyword">new</span> StandardRoot();
<span class="hljs-keyword">if</span> (development) {
resources.setCachingAllowed(<span class="hljs-keyword">false</span>);
} <span class="hljs-keyword">else</span> {
resources.setCacheMaxSize(<span class="hljs-number">100000</span>);
resources.setCacheObjectMaxSize(<span class="hljs-number">4000</span>);
resources.setCacheTtl(<span class="hljs-number">24</span> * <span class="hljs-number">3600</span> * <span class="hljs-number">1000</span>); <span class="hljs-comment">// 1 day, in milliseconds</span>
}
context.setResources(resources);
<span class="hljs-comment">// Put Jasper in production mode so that JSP aren't recompiled</span>
<span class="hljs-comment">// on each request.</span>
<span class="hljs-comment">// See http://stackoverflow.com/questions/29653326/spring-boot-application-slow-because-of-jsp-compilation</span>
Container jsp = context.findChild(<span class="hljs-string">"jsp"</span>);
<span class="hljs-keyword">if</span> (jsp <span class="hljs-keyword">instanceof</span> Wrapper) {
((Wrapper) jsp).addInitParameter(<span class="hljs-string">"development"</span>, Boolean.toString(development));
}
});
}
示例8: customizeBackgroundProcessorDelay
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
private void customizeBackgroundProcessorDelay(
TomcatEmbeddedServletContainerFactory factory) {
factory.addContextCustomizers(new TomcatContextCustomizer() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(Context context)</span> </span>{
context.setBackgroundProcessorDelay(
Tomcat.<span class="hljs-keyword">this</span>.backgroundProcessorDelay);
}
});
}
示例9: customizeRedirectContextRoot
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
private void customizeRedirectContextRoot(
TomcatEmbeddedServletContainerFactory factory,
final boolean redirectContextRoot) {
factory.addContextCustomizers(new TomcatContextCustomizer() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(Context context)</span> </span>{
context.setMapperContextRootRedirectEnabled(redirectContextRoot);
}
});
}
示例10: doCustomize
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Override
public void doCustomize(TomcatEmbeddedServletContainerFactory tomcatContainer) {
tomcatContainer.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
addListener(context, findListenerType());
}
});
}
示例11: tomcatContextCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public TomcatContextCustomizer tomcatContextCustomizer() {
return new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
context.addApplicationListener("org.apache.tomcat.websocket.server.WsContextListener");
}
};
}
示例12: factory
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean public TomcatEmbeddedServletContainerFactory factory() {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
tomcatEmbeddedServletContainerFactory.addContextCustomizers((TomcatContextCustomizer) (Context context) -> {
context.addServletContainerInitializer(new JasperInitializer(), Collections.<Class<?>> emptySet());
});
return tomcatEmbeddedServletContainerFactory;
}
示例13: servletContainerCustomizer
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(ConfigurableEmbeddedServletContainer container)</span> </span>{
<span class="hljs-keyword">if</span> (container <span class="hljs-keyword">instanceof</span> TomcatEmbeddedServletContainerFactory) {
customizeTomcat((TomcatEmbeddedServletContainerFactory)container);
}
}
<span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customizeTomcat</span><span class="hljs-params">(TomcatEmbeddedServletContainerFactory tomcatFactory)</span> </span>{
tomcatFactory.addContextCustomizers(<span class="hljs-keyword">new</span> <span class="highlight">TomcatContextCustomizer</span>() {
<span class="hljs-meta">@Override</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">customize</span><span class="hljs-params">(Context context)</span> </span>{
Container jsp = context.findChild(<span class="hljs-string">"jsp"</span>);
<span class="hljs-keyword">if</span> (jsp <span class="hljs-keyword">instanceof</span> Wrapper) {
((Wrapper)jsp).addInitParameter(<span class="hljs-string">"development"</span>, <span class="hljs-string">"false"</span>);
}
}
});
}
};
}
示例14: tomcatContainerFactory
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; //导入依赖的package包/类
@Bean
public TomcatEmbeddedServletContainerFactory tomcatContainerFactory() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.setTomcatContextCustomizers(
Arrays.asList(new TomcatContextCustomizer[] { tomcatContextCustomizer() }));
return factory;
}