本文整理汇总了Java中org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory类的典型用法代码示例。如果您正苦于以下问题:Java JettyEmbeddedServletContainerFactory类的具体用法?Java JettyEmbeddedServletContainerFactory怎么用?Java JettyEmbeddedServletContainerFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JettyEmbeddedServletContainerFactory类属于org.springframework.boot.context.embedded.jetty包,在下文中一共展示了JettyEmbeddedServletContainerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jettyEmbeddedServletContainerFactory
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
/**
* Configures the embedded jetty server. The values are configured in
* <b>application.yaml</b> file.
*
* @param port jetty server port
* @param maxThreads thread pool min thread
* @param minThreads thread pool max thread
* @param idleTimeout maximum thread idle time
* @param jmxEnabled true, if jetty jmx is enabled.
* @return {@link JettyEmbeddedServletContainerFactory}
*/
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(@Value("${server.port:8443}") final int port,
@Value("${jetty.thread-pool.max-threads:200}") final int maxThreads,
@Value("${jetty.thread-pool.min-threads:8}") final int minThreads,
@Value("${jetty.thread-pool.idle-timeout:60000}") final int idleTimeout,
@Value("${jetty.jmx.enabled:true}") final boolean jmxEnabled) {
log.info("Configuring Jetty server.");
final JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(port);
factory.addServerCustomizers(server -> {
final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
threadPool.setMinThreads(minThreads);
threadPool.setMaxThreads(maxThreads);
threadPool.setIdleTimeout(idleTimeout);
log.info("Server thread pool config: " + server.getThreadPool());
// Jetty JMX config.
if (jmxEnabled) {
log.info("Exposing Jetty managed beans to the JMX platform server.");
server.addBean(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
}
});
return factory;
}
示例2: jettyConfigBean
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
DynamicPropertyFactory propertyFactory = DynamicPropertyFactory.getInstance();
String accessLogFilePath = propertyFactory.getStringProperty("server.accessLog.config.file", ACCESS_LOG_FILE_PATH).getValue();
JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory
= new JettyEmbeddedServletContainerFactory();
jettyEmbeddedServletContainerFactory.addServerCustomizers(new org.springframework.boot.context.embedded.jetty.JettyServerCustomizer() {
public void customize(Server server) {
HandlerCollection handlers = new HandlerCollection();
for (Handler handler : server.getHandlers()) {
handlers.addHandler(handler);
}
RequestLogHandler requestLogHandler = new RequestLogHandler();
RequestLogImpl requestLogImpl = new RequestLogImpl();
requestLogImpl.setFileName(accessLogFilePath);
requestLogHandler.setRequestLog(requestLogImpl);
handlers.addHandler(requestLogHandler);
server.setHandler(handlers);
LOGGER.info("Jetty Server Customized. Access Log Configuration File - {}", accessLogFilePath);
}
});
return jettyEmbeddedServletContainerFactory;
}
示例3: servletContainerCustomizer
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
@Autowired
public EmbeddedServletContainerCustomizer servletContainerCustomizer(ServerProperties properties) {
return container -> {
if (container instanceof JettyEmbeddedServletContainerFactory) {
JettyEmbeddedServletContainerFactory jettyContainer = (JettyEmbeddedServletContainerFactory) container;
jettyContainer.addConfigurations(new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
properties.getContextParameters().forEach((k, v) -> context.setInitParameter(k, v));
}
});
}
};
}
示例4: customizeJetty
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
void customizeJetty(final ServerProperties serverProperties,
JettyEmbeddedServletContainerFactory factory) {
factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders());
if (this.acceptors != null) {
factory.setAcceptors(this.acceptors);
}
if (this.selectors != null) {
factory.setSelectors(this.selectors);
}
if (serverProperties.getMaxHttpHeaderSize() > 0) {
customizeMaxHttpHeaderSize(factory,
serverProperties.getMaxHttpHeaderSize());
}
if (serverProperties.getMaxHttpPostSize() > 0) {
customizeMaxHttpPostSize(factory, serverProperties.getMaxHttpPostSize());
}
if (serverProperties.getConnectionTimeout() != null) {
customizeConnectionTimeout(factory,
serverProperties.getConnectionTimeout());
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:ServerProperties.java
示例5: customizeConnectionTimeout
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
private void customizeConnectionTimeout(
JettyEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
factory.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
for (org.eclipse.jetty.server.Connector connector : server
.getConnectors()) {
if (connector instanceof AbstractConnector) {
((AbstractConnector) connector)
.setIdleTimeout(connectionTimeout);
}
}
}
});
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:ServerProperties.java
示例6: customizeJetty
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
void customizeJetty(ServerProperties serverProperties,
JettyEmbeddedServletContainerFactory factory) {
factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders());
if (this.acceptors != null) {
factory.setAcceptors(this.acceptors);
}
if (this.selectors != null) {
factory.setSelectors(this.selectors);
}
if (serverProperties.getMaxHttpHeaderSize() > 0) {
customizeMaxHttpHeaderSize(factory,
serverProperties.getMaxHttpHeaderSize());
}
if (serverProperties.getMaxHttpPostSize() > 0) {
customizeMaxHttpPostSize(factory, serverProperties.getMaxHttpPostSize());
}
}
示例7: disableServerHeader
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerCustomizer disableServerHeader() {
return container -> {
if (container instanceof JettyEmbeddedServletContainerFactory) {
((JettyEmbeddedServletContainerFactory) container).addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
for (Connector connector : server.getConnectors()) {
if (connector instanceof ServerConnector) {
HttpConnectionFactory connectionFactory = connector.getConnectionFactory(HttpConnectionFactory.class);
connectionFactory.getHttpConfiguration().setSendServerVersion(false);
}
}
}
});
}
};
}
示例8: jettyEmbeddedServletContainerFactory
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(
@Value("${server.port:8080}") final String port,
@Value("${jetty.threadPool.maxThreads:200}") final String maxThreads,
@Value("${jetty.threadPool.minThreads:8}") final String minThreads,
@Value("${jetty.threadPool.idleTimeout:60000}") final String idleTimeout) {
final JettyEmbeddedServletContainerFactory factory =
new JettyEmbeddedServletContainerFactory(Integer.valueOf(port));
factory.addServerCustomizers((JettyServerCustomizer) server -> {
final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
threadPool.setMaxThreads(Integer.valueOf(maxThreads));
threadPool.setMinThreads(Integer.valueOf(minThreads));
threadPool.setIdleTimeout(Integer.valueOf(idleTimeout));
final GzipHandler gzipHandler = new GzipHandler();
gzipHandler.setHandler(server.getHandler());
gzipHandler.setSyncFlush(true);
server.setHandler(gzipHandler);
});
return factory;
}
示例9: addStatisticHandler
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
private void addStatisticHandler(JettyEmbeddedServletContainerFactory jetty) {
jetty.addServerCustomizers(server -> {
HandlerCollection handlerCollection = new HandlerCollection(server.getHandlers());
statisticsHandler.setHandler(handlerCollection);
server.setHandler(statisticsHandler);
});
}
示例10: customizeJetty
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Override
void customizeJetty(JettyEmbeddedServletContainerFactory container) {
container.addServerCustomizers(server -> {
RequestLogHandler requestLogsHandler = new RequestLogHandler();
requestLogsHandler.setServer(server);
Slf4jRequestLog log = new Slf4jRequestLog();
requestLogsHandler.setRequestLog(log);
HandlerCollection handlers = new HandlerCollection(server.getHandlers());
handlers.prependHandler(requestLogsHandler);
server.setHandler(handlers);
});
}
示例11: jettyCustomizer
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public JettyCustomizer jettyCustomizer() {
return new JettyCustomizer() {
@Override
void customizeJetty(JettyEmbeddedServletContainerFactory container) {
String serverName = "jetty";
container.setServerHeader(serverName);
container.setDisplayName(serverName);
container.setUseForwardHeaders(true);
}
};
}
示例12: customizeJetty
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Override
void customizeJetty(JettyEmbeddedServletContainerFactory container) {
container.addServerCustomizers(server -> {
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addEventListener(mbContainer);
server.addBean(mbContainer);
});
}
示例13: jettyConfigBean
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
/**
* @return Jetty config bean
*/
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
jef.setPort(getServerPort());
logger.info("Listening on port {}...", jef.getPort());
return jef;
}
示例14: containerFactory
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory containerFactory() {
JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(
0);
factory.setContextPath(this.env.getProperty("context"));
return factory;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:EmbeddedServletContainerMvcIntegrationTests.java
示例15: doCustomize
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; //导入依赖的package包/类
@Override
protected void doCustomize(JettyEmbeddedServletContainerFactory container) {
container.addConfigurations(new AbstractConfiguration() {
@Override
public void configure(WebAppContext context) throws Exception {
ServerContainer serverContainer = WebSocketServerContainerInitializer
.configureContext(context);
ShutdownThread.deregister(serverContainer);
}
});
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JettyWebSocketContainerCustomizer.java