當前位置: 首頁>>代碼示例>>Java>>正文


Java TomcatEmbeddedServletContainerFactory.addConnectorCustomizers方法代碼示例

本文整理匯總了Java中org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.addConnectorCustomizers方法的典型用法代碼示例。如果您正苦於以下問題:Java TomcatEmbeddedServletContainerFactory.addConnectorCustomizers方法的具體用法?Java TomcatEmbeddedServletContainerFactory.addConnectorCustomizers怎麽用?Java TomcatEmbeddedServletContainerFactory.addConnectorCustomizers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory的用法示例。


在下文中一共展示了TomcatEmbeddedServletContainerFactory.addConnectorCustomizers方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: customizeMaxHttpHeaderSize

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(
		TomcatEmbeddedServletContainerFactory factory,
		final int maxHttpHeaderSize) {
	factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

		@Override
		public void customize(Connector connector) {
			ProtocolHandler handler = connector.getProtocolHandler();
			if (handler instanceof AbstractHttp11Protocol) {
				AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) handler;
				protocol.setMaxHttpHeaderSize(maxHttpHeaderSize);
			}
		}

	});
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:18,代碼來源:ServerProperties.java

示例3: containerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
/**
 * Container customizer. Configures the embedded tomcat (e.g. post size)
 *
 * @return the embedded servlet container customizer
 * @throws Exception the exception
 */
@Bean 
public EmbeddedServletContainerCustomizer containerCustomizer(
        ) throws Exception {
 
      
      return new EmbeddedServletContainerCustomizer() {
		@Override
		public void customize(ConfigurableEmbeddedServletContainer container) {

		      if (container instanceof TomcatEmbeddedServletContainerFactory) {

		          TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
		          tomcat.addConnectorCustomizers(
		                  new TomcatConnectorCustomizer() {
							@Override
							public void customize(Connector connector) {
								  connector.setMaxPostSize(20000000);//20MB
							  }
						}
		          );
		      }
		  }
	};
  }
 
開發者ID:andju,項目名稱:findlunch,代碼行數:31,代碼來源:Beans.java

示例4: 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

示例5: 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

示例6: containerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@Bean
EmbeddedServletContainerCustomizer containerCustomizer() throws Exception {
    return (ConfigurableEmbeddedServletContainer container) -> {
        if (container instanceof TomcatEmbeddedServletContainerFactory) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(
                    (connector) -> {
                        connector.setMaxPostSize(1000000000); // 1000 MB
                    }
            );
        }
    };
}
 
開發者ID:weiboad,項目名稱:fiery,代碼行數:14,代碼來源:RagnarApplication.java

示例7: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();

    tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
        connector.setScheme("http");
        connector.setPort(cfg.getPort());
    });

    return tomcat;
}
 
開發者ID:kamax-io,項目名稱:mxhsd,代碼行數:12,代碼來源:MxhsdClientApp.java

示例8: createEmbeddedServletContainerFactory

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@Bean
public EmbeddedServletContainerFactory createEmbeddedServletContainerFactory() {
    TomcatEmbeddedServletContainerFactory tomcatFactory = new TomcatEmbeddedServletContainerFactory();
    tomcatFactory.setUriEncoding(StandardCharsets.UTF_8);
    tomcatFactory.setSessionTimeout(3600, TimeUnit.SECONDS);
    tomcatFactory.addConnectorCustomizers(new MyTomcatConnectorCustomizer());
    return tomcatFactory;
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:9,代碼來源:WebServerConfig.java

示例9: customizeTomcat

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
public void customizeTomcat(TomcatEmbeddedServletContainerFactory factory) {
	factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
		@Override
		public void customize(Connector connector) {
			Object defaultMaxThreads = connector.getAttribute("maxThreads");
			connector.setAttribute("maxThreads", MAX_THREADS);
			LOG.info("Changed Tomcat connector maxThreads from " + defaultMaxThreads + " to " + MAX_THREADS);
		}
	});
}
 
開發者ID:Myazure,項目名稱:weixin_component,代碼行數:11,代碼來源:MyazureEmbeddedServletContainerCustomizer.java

示例10: customizeMaxThreads

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void customizeMaxThreads(TomcatEmbeddedServletContainerFactory factory) {
	factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
		@Override
		public void customize(Connector connector) {

			ProtocolHandler handler = connector.getProtocolHandler();
			if (handler instanceof AbstractProtocol) {
				AbstractProtocol protocol = (AbstractProtocol) handler;
				protocol.setMaxThreads(Tomcat.this.maxThreads);
			}

		}
	});
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:16,代碼來源:ServerProperties.java

示例11: customizeMinThreads

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void customizeMinThreads(TomcatEmbeddedServletContainerFactory factory) {
	factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
		@Override
		public void customize(Connector connector) {

			ProtocolHandler handler = connector.getProtocolHandler();
			if (handler instanceof AbstractProtocol) {
				AbstractProtocol protocol = (AbstractProtocol) handler;
				protocol.setMinSpareThreads(Tomcat.this.minSpareThreads);
			}

		}
	});
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:16,代碼來源:ServerProperties.java

示例12: customizeMaxHttpPostSize

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
private void customizeMaxHttpPostSize(
		TomcatEmbeddedServletContainerFactory factory,
		final int maxHttpPostSize) {
	factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

		@Override
		public void customize(Connector connector) {
			connector.setMaxPostSize(maxHttpPostSize);
		}

	});
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:ServerProperties.java

示例13: servletContainerCustomizer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
/**
 * Configure embedded tomcat so that is use gzip for various resources.
 */
@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 StringBuffer mimeTypes = new StringBuffer(httpProtocol.getCompressableMimeType());
					if(!mimeTypes.toString().contains("MediaType.APPLICATION_JSON_VALUE"))
					{
						mimeTypes.append(","+MediaType.APPLICATION_JSON_VALUE);
					}
					if(!mimeTypes.toString().contains("application/javascript"))
					{
						mimeTypes.append(",application/javascript");
					}
					httpProtocol.setCompressableMimeType(mimeTypes.toString());
				}
			});
		}
	};
}
 
開發者ID:metasfresh,項目名稱:metasfresh-procurement-webui,代碼行數:36,代碼來源:Application.java

示例14: servletContainer

import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; //導入方法依賴的package包/類
@Bean
public EmbeddedServletContainerCustomizer servletContainer() {
    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            // By default Tomcat terminates the connection after 30s. Browser should reconnect by itself
            // in such case, but we can avoid the waste by removing the timeout.
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(connector -> connector.setAsyncTimeout(0));
        }
    };
}
 
開發者ID:OasisDigital,項目名稱:nges-sample-tic-tac-toe,代碼行數:13,代碼來源:TicTacToe.java


注:本文中的org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.addConnectorCustomizers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。