本文整理汇总了Java中org.springframework.boot.context.embedded.EmbeddedServletContainerFactory类的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedServletContainerFactory类的具体用法?Java EmbeddedServletContainerFactory怎么用?Java EmbeddedServletContainerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmbeddedServletContainerFactory类属于org.springframework.boot.context.embedded包,在下文中一共展示了EmbeddedServletContainerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
connector.setScheme("https");
connector.setPort(cfg.getPort());
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
protocol.setSSLEnabled(true);
protocol.setSSLCertificateKeyFile(cfg.getKey());
protocol.setSSLCertificateFile(cfg.getCert());
cfg.getChain().ifPresent(protocol::setSSLCertificateChainFile);
});
return tomcat;
}
示例2: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}
示例3: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
final TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
if (isEnabled()) {
final Connector ajpConnector = new Connector(getProtocol());
ajpConnector.setPort(getPort());
ajpConnector.setSecure(isSecure());
ajpConnector.setAllowTrace(isAllowTrace());
ajpConnector.setScheme(getScheme());
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
return tomcat;
}
示例4: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer(SslProperties properties) {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(createSslConnector(properties));
return tomcat;
}
示例5: jettyConfigBean
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的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;
}
示例6: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
final TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory();
// tomcatFactory.setAddress(InetAddress.getLocalHost());// you can restrict localhost access
tomcatFactory.setPort(8080);
// ServletContainerInitializer
final Connector connector = new Connector();
connector.setPort(8443);
connector.setSecure(true);
connector.setScheme("https");
connector.setProperty("SSLEnabled", "true");
connector.setProperty("keystorePass", "spring");
try {
final ClassPathResource classPathResource = new ClassPathResource("keystore");
System.err.println(classPathResource.getFile().getAbsolutePath());
connector.setProperty("keystoreFile", classPathResource.getFile().getAbsolutePath());
} catch (final Exception e) {
System.err.println("Error while loading classpath resource " + e.getMessage());
}
tomcatFactory.addAdditionalTomcatConnectors(connector);
return tomcatFactory;
}
示例7: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
/**
* <p>servletContainer.</p>
*
* @return a {@link org.springframework.boot.context.embedded.EmbeddedServletContainerFactory} object.
*/
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}
示例8: onDifferentPortWithSpecificContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Test
public void onDifferentPortWithSpecificContainer() throws Exception {
this.applicationContext.register(SpecificContainerConfig.class, RootConfig.class,
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/error", ports.get().management, startsWith("{"));
ApplicationContext managementContext = this.applicationContext
.getBean(ManagementContextResolver.class).getApplicationContext();
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
assertThat(interceptors).hasSize(1);
EmbeddedServletContainerFactory parentContainerFactory = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class);
EmbeddedServletContainerFactory managementContainerFactory = managementContext
.getBean(EmbeddedServletContainerFactory.class);
assertThat(parentContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory)
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
assertThat(managementContainerFactory).isNotSameAs(parentContainerFactory);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:EndpointWebMvcAutoConfigurationTests.java
示例9: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}
示例10: embeddedServletContainerFactory
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
/**
* TODO: support Jetty as well
*/
@Bean
public EmbeddedServletContainerFactory embeddedServletContainerFactory(ApplicationContext ctx) {
String portProp = System.getProperty("mdw.server.port");
if (portProp == null)
portProp = System.getProperty("server.port");
if (portProp == null)
portProp = "8080";
String contextProp = System.getProperty("mdw.server.contextPath");
if (contextProp == null)
contextProp = System.getProperty("server.contextPath");
if (contextProp == null)
contextProp = "/mdw";
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(
contextProp, Integer.parseInt(portProp));
factory.addContextCustomizers(tomcatContextCustomizer());
factory.setDocumentRoot(new File(getBootDir() + "/web"));
return factory;
}
示例11: registerEmbeddedServletContainerFactory
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
private void registerEmbeddedServletContainerFactory(
AnnotationConfigEmbeddedWebApplicationContext childContext) {
try {
EmbeddedServletContainerFactory servletContainerFactory = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class);
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition("embeddedServletContainerFactory",
new RootBeanDefinition(servletContainerFactory.getClass()));
}
}
catch (NoSuchBeanDefinitionException ex) {
// Ignore and assume auto-configuration
}
}
示例12: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
if (https) {
TomcatEmbeddedServletContainerFactory tomcat =
new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}
return new TomcatEmbeddedServletContainerFactory();
}
示例13: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
Integer ajpPortInt = Integer.parseInt(ajpPort);
Boolean ajpEnabledBool = Boolean.valueOf(ajpEnabled);
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
if (ajpEnabledBool)
{
Connector ajpConnector = new Connector(ajpProtocol);
ajpConnector.setProtocol(ajpProtocol);
ajpConnector.setPort(ajpPortInt);
ajpConnector.setSecure(false);
ajpConnector.setAllowTrace(false);
ajpConnector.setScheme(ajpScheme);
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
return tomcat;
}
示例14: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer()
{
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory()
{
@Override
protected void postProcessContext(Context context)
{
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}
示例15: servletContainer
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; //导入依赖的package包/类
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(initiateHttpConnector());
return tomcat;
}