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