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


Java TomcatEmbeddedServletContainerFactory类代码示例

本文整理汇总了Java中org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory的典型用法代码示例。如果您正苦于以下问题:Java TomcatEmbeddedServletContainerFactory类的具体用法?Java TomcatEmbeddedServletContainerFactory怎么用?Java TomcatEmbeddedServletContainerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TomcatEmbeddedServletContainerFactory类属于org.springframework.boot.context.embedded.tomcat包,在下文中一共展示了TomcatEmbeddedServletContainerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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: customize

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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);
      }

    }
  });
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:25,代码来源:TomcatContainerCustomizer.java

示例3: configureRewriteValve

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的package包/类
private void configureRewriteValve(final TomcatEmbeddedServletContainerFactory tomcat) {
    final Resource res = casProperties.getServer().getRewriteValveConfigLocation();
    if (ResourceUtils.doesResourceExist(res)) {
        final RewriteValve valve = new RewriteValve() {
            @Override
            protected synchronized void startInternal() throws LifecycleException {
                super.startInternal();
                try (InputStream is = res.getInputStream();
                     InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
                     BufferedReader buffer = new BufferedReader(isr)) {
                    parse(buffer);
                } catch (final Exception e) {
                    throw Throwables.propagate(e);
                }
            }
        };
        valve.setAsyncSupported(true);
        valve.setEnabled(true);

        LOGGER.debug("Creating Rewrite valve configuration for the embedded tomcat container...");
        tomcat.addContextValves(valve);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:CasEmbeddedContainerTomcatConfiguration.java

示例4: configureExtendedAccessLogValve

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的package包/类
private void configureExtendedAccessLogValve(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasServerProperties.ExtendedAccessLog ext = casProperties.getServer().getExtAccessLog();

    if (ext.isEnabled() && StringUtils.isNotBlank(ext.getPattern())) {
        LOGGER.debug("Creating extended access log valve configuration for the embedded tomcat container...");
        final ExtendedAccessLogValve valve = new ExtendedAccessLogValve();
        valve.setPattern(ext.getPattern());

        if (StringUtils.isBlank(ext.getDirectory())) {
            valve.setDirectory(serverProperties.getTomcat().getAccesslog().getDirectory());
        } else {
            valve.setDirectory(ext.getDirectory());
        }
        valve.setPrefix(ext.getPrefix());
        valve.setSuffix(ext.getSuffix());
        valve.setAsyncSupported(true);
        valve.setEnabled(true);
        valve.setRotatable(true);
        valve.setBuffered(true);
        tomcat.addContextValves(valve);
        tomcat.addEngineValves(valve);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:CasEmbeddedContainerTomcatConfiguration.java

示例5: configureHttp

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的package包/类
private void configureHttp(final TomcatEmbeddedServletContainerFactory tomcat) {
    final CasServerProperties.Http http = casProperties.getServer().getHttp();
    if (http.isEnabled()) {
        LOGGER.debug("Creating HTTP configuration for the embedded tomcat container...");
        final Connector connector = new Connector(http.getProtocol());
        int port = http.getPort();
        if (port <= 0) {
            LOGGER.warn("No explicit port configuration is provided to CAS. Scanning for available ports...");
            port = SocketUtils.findAvailableTcpPort();
        }
        LOGGER.info("Activated embedded tomcat container HTTP port to [{}]", port);
        connector.setPort(port);

        LOGGER.debug("Configuring embedded tomcat container for HTTP2 protocol support");
        connector.addUpgradeProtocol(new Http2Protocol());

        http.getAttributes().forEach(connector::setAttribute);
        tomcat.addAdditionalTomcatConnectors(connector);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:CasEmbeddedContainerTomcatConfiguration.java

示例6: purgeAccessLogCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的package包/类
/**
 * Purge access log customizer embedded servlet container customizer.
 *
 * @param serverProperties the server properties
 * @param purgeProperties  the purge properties
 * @return the embedded servlet container customizer
 */
@Bean
public EmbeddedServletContainerCustomizer purgeAccessLogCustomizer(
        final ServerProperties serverProperties,
        final PurgeProperties purgeProperties) {
    return container -> {
        final TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container;
        final Accesslog accesslog = serverProperties.getTomcat().getAccesslog();
        factory.getEngineValves().stream()
                .filter(valve -> valve instanceof AccessLogValve)
                .map(valve -> (AccessLogValve) valve).findFirst()
                .ifPresent(valve -> {
                    final TomcatPurgeAccessLogHolder accessLogHolder = new TomcatPurgeAccessLogHolder(
                            purgeProperties, Paths.get(accesslog.getDirectory()),
                            accesslog.getPrefix(), accesslog.getSuffix(), valve);
                    factory.addContextCustomizers(accessLogHolder);
                });
    };
}
 
开发者ID:marcosbarbero,项目名称:spring-boot-starter-purge-accesslog,代码行数:26,代码来源:PurgeAccessLogAutoConfiguration.java

示例7: cookieProcessorCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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());
                    }                        
                });
            }
        }

    };
}
 
开发者ID:intuit,项目名称:karate,代码行数:19,代码来源:TomcatConfig.java

示例8: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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

示例9: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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

示例10: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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

示例11: embeddedServletContainerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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());
            }
        }
    };
}
 
开发者ID:xiaowing,项目名称:various_demos,代码行数:24,代码来源:Application.java

示例12: embeddedServletContainerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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);
            }
        }
    };
}
 
开发者ID:xiaowing,项目名称:various_demos,代码行数:21,代码来源:EmbeddedTomcatConfig.java

示例13: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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

示例14: servletContainerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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);
				}
			});
		}
	};
}
 
开发者ID:metasfresh,项目名称:metasfresh-webui-api,代码行数:26,代码来源:WebRestApiApplication.java

示例15: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //导入依赖的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


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