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


Java EmbeddedServletContainerFactory类代码示例

本文整理汇总了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;
}
 
开发者ID:kamax-io,项目名称:mxhsd,代码行数:17,代码来源:MxhsdFederationApp.java

示例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;
}
 
开发者ID:sfahadahmed,项目名称:hungrydragon,代码行数:18,代码来源:TomcatConfig.java

示例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;
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:17,代码来源:TomcatConfiguration.java

示例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;
}
 
开发者ID:Saisimon,项目名称:tip,代码行数:17,代码来源:TomcatWebConfig.java

示例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;
}
 
开发者ID:andrewharmellaw,项目名称:jetty-server-request-logger,代码行数:26,代码来源:JettyServerCustomizer.java

示例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;
}
 
开发者ID:tvajjala,项目名称:interview-preparation,代码行数:25,代码来源:DispatchServletConfig.java

示例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;
}
 
开发者ID:rajadilipkolli,项目名称:springsecuredthymeleafapp,代码行数:23,代码来源:WebConfiguration.java

示例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;
}
 
开发者ID:bhits,项目名称:edge-server,代码行数:17,代码来源:WebConfig.java

示例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;
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw,代码行数:22,代码来源:SpringBootApplication.java

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

示例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();
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:22,代码来源:SystemConfiguration.java

示例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;
}
 
开发者ID:markquinn12,项目名称:springBoot-JHipster-AJP-Port,代码行数:21,代码来源:Application.java

示例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;
}
 
开发者ID:sivaprasadreddy,项目名称:jcart,代码行数:21,代码来源:WebConfig.java

示例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;
}
 
开发者ID:sivaprasadreddy,项目名称:jcart,代码行数:18,代码来源:WebConfig.java


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