本文整理汇总了Java中org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableEmbeddedServletContainer类的具体用法?Java ConfigurableEmbeddedServletContainer怎么用?Java ConfigurableEmbeddedServletContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurableEmbeddedServletContainer类属于org.springframework.boot.context.embedded包,在下文中一共展示了ConfigurableEmbeddedServletContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (!(container instanceof TomcatEmbeddedServletContainerFactory)) {
return;
}
if (!environment.containsProperty(TOMCAT_ACCEPTOR_COUNT)) {
return;
}
TomcatEmbeddedServletContainerFactory tomcat =
(TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof Http11NioProtocol) {
Http11NioProtocol http = (Http11NioProtocol) handler;
int acceptCount = Integer.parseInt(environment.getProperty(TOMCAT_ACCEPTOR_COUNT));
http.setBacklog(acceptCount);
logger.info("Setting tomcat accept count to {}", acceptCount);
}
}
});
}
示例2: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path
container.setContextPath("");
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
if (this.managementServerProperties.getSsl() != null) {
container.setSsl(this.managementServerProperties.getSsl());
}
container.setServerHeader(this.server.getServerHeader());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:EndpointWebMvcChildContextConfiguration.java
示例3: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
* Customize the Servlet engine: Mime types, the document root, the cache.
*/
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
mappings.add("html", "text/html;charset=utf-8");
// CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
mappings.add("json", "text/html;charset=utf-8");
container.setMimeMappings(mappings);
/*
* Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
* HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
* See the JHipsterProperties class and your application-*.yml configuration files
* for more information.
*/
if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
container instanceof UndertowEmbeddedServletContainerFactory) {
((UndertowEmbeddedServletContainerFactory) container)
.addBuilderCustomizers(builder ->
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
}
}
示例4: cookieProcessorCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的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());
}
});
}
}
};
}
示例5: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
logger.info("Customizing EmbeddedServlet");
Integer serverPort;
{ // setup the server port using the env vars
String engineServerPortString = System.getenv().get(ENGINE_SERVER_PORT_KEY);
if (engineServerPortString == null) {
logger.error("FAILED to find env var [{}], will use defaults for engine server port", ENGINE_SERVER_PORT_KEY);
serverPort = defaultServerPort;
} else {
logger.info("FOUND env var [{}], will use for engine server port", ENGINE_SERVER_PORT_KEY);
serverPort = Integer.parseInt(engineServerPortString);
}
}
logger.info("setting serverPort[{}]", serverPort);
container.setPort(serverPort);
}
示例6: containerCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
ErrorPage page404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404");
container.addErrorPages(page404);
}
};
// return (container -> {
// ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
// ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
// ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
//
// container.addErrorPages(error401Page, error404Page, error500Page);
// });
}
示例7: embeddedServletContainerCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = (TomcatEmbeddedServletContainerFactory) container;
RedisSessionHandlerValve valve = new RedisSessionHandlerValve();
List<RedisSessionHandlerValve> valves =
new ArrayList<RedisSessionHandlerValve>();
valves.add(0, valve);
tomcatEmbeddedServletContainerFactory.setContextValves(valves);
tomcatEmbeddedServletContainerFactory.setPort(28080); // Set the port of embeded tomcat as 28080 for default.
System.out.println("Enterring EmbeddedServletContainerCustomizer.customize()...");
tomcatEmbeddedServletContainerFactory.addContextCustomizers(
new ServletContainerCustomizer());
}
}
};
}
示例8: embeddedServletContainerCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {
return new EmbeddedServletContainerCustomizer() {
@Value("${application.port}")
private int embeddedServletContainerListenPort;
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory =
(TomcatEmbeddedServletContainerFactory) container;
if (embeddedServletContainerListenPort <= 1024 || embeddedServletContainerListenPort > 65535) {
throw new IllegalArgumentException("The value of \"application.port\" in the properties file is invalid.");
}
tomcatEmbeddedServletContainerFactory.setPort(embeddedServletContainerListenPort);
}
}
};
}
示例9: servletContainerCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer()
{
return new EmbeddedServletContainerCustomizer()
{
@Override
public void customize(final ConfigurableEmbeddedServletContainer servletContainer)
{
final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory)servletContainer;
tomcatContainerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer()
{
@Override
public void customize(final Connector connector)
{
final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>)connector.getProtocolHandler();
httpProtocol.setCompression("on");
httpProtocol.setCompressionMinSize(256);
final String mimeTypes = httpProtocol.getCompressibleMimeType();
final String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript";
httpProtocol.setCompressibleMimeType(mimeTypesWithJson);
}
});
}
};
}
示例10: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
* Set up Mime types and, if needed, set the document root.
*/
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
mappings.add("html", "text/html;charset=utf-8");
// CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
mappings.add("json", "text/html;charset=utf-8");
container.setMimeMappings(mappings);
// When running in an IDE or with ./gradlew bootRun, set location of the static web assets.
File root;
if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) {
root = new File("build/www/");
} else {
root = new File("src/main/webapp/");
}
if (root.exists() && root.isDirectory()) {
container.setDocumentRoot(root);
}
}
示例11: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
* Set up Mime types and, if needed, set the document root.
*/
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
mappings.add("html", "text/html;charset=utf-8");
// CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
mappings.add("json", "text/html;charset=utf-8");
container.setMimeMappings(mappings);<% if (!skipClient) { %>
// When running in an IDE or with <% if (buildTool == 'gradle') { %>./gradlew bootRun<% } else { %>./mvnw spring-boot:run<% } %>, set location of the static web assets.
File root;
if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) {
root = new File("<%= CLIENT_DIST_DIR %>");
} else {
root = new File("<%= CLIENT_MAIN_SRC_DIR %>");
}
if (root.exists() && root.isDirectory()) {
container.setDocumentRoot(root);
}<% } %>
}
示例12: containerCustomizer
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
* Container customizer. Configures the embedded tomcat (e.g. post size)
*
* @return the embedded servlet container customizer
* @throws Exception the exception
*/
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer(
) throws Exception {
return new EmbeddedServletContainerCustomizer() {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(
new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
connector.setMaxPostSize(20000000);//20MB
}
}
);
}
}
};
}
示例13: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
KeystoreConfig cert = configureKeystore();
if(cert == null) {
log.debug("Ssl is not enabled due to no any configured keystore.");
return;
}
String keystorePath = cert.getKeystore().getAbsolutePath();
log.debug("Configure ssl with {} keystore.", keystorePath);
Ssl ssl = new Ssl();
ssl.setEnabled(true);
ssl.setKeyStore(keystorePath);
ssl.setKeyStorePassword(cert.getKeystorePassword());
ssl.setKeyPassword(cert.getKeyPassword());
container.setSsl(ssl);
}
示例14: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
* Customize the Servlet engine: Mime types, the document root, the cache.
*/
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
mappings.add("html", "text/html;charset=utf-8");
// CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
mappings.add("json", "text/html;charset=utf-8");
container.setMimeMappings(mappings);
// When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
setLocationForStaticAssets(container);
/*
* Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
* HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
* See the JHipsterProperties class and your application-*.yml configuration files
* for more information.
*/
if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
container instanceof UndertowEmbeddedServletContainerFactory) {
((UndertowEmbeddedServletContainerFactory) container)
.addBuilderCustomizers(builder ->
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
}
}
示例15: customize
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
if (this.managementServerProperties == null) {
this.managementServerProperties = BeanFactoryUtils
.beanOfTypeIncludingAncestors(this.beanFactory,
ManagementServerProperties.class);
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
this.beanFactory, ServerProperties.class);
}
// Customize as per the parent context first (so e.g. the access logs go to
// the same place)
this.server.customize(container);
// Then reset the error pages
container.setErrorPages(Collections.<ErrorPage>emptySet());
// and the context path
container.setContextPath("");
// and add the management-specific bits
container.setPort(this.managementServerProperties.getPort());
container.setServerHeader(this.server.getServerHeader());
container.setAddress(this.managementServerProperties.getAddress());
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}