當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。