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


Java ConfigurableEmbeddedServletContainer类代码示例

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


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

示例1: customize

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

示例2: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	if (this.managementServerProperties == null) {
		this.managementServerProperties = BeanFactoryUtils
				.beanOfTypeIncludingAncestors(this.beanFactory,
						ManagementServerProperties.class);
		this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
				this.beanFactory, ServerProperties.class);
	}
	// Customize as per the parent context first (so e.g. the access logs go to
	// the same place)
	this.server.customize(container);
	// Then reset the error pages
	container.setErrorPages(Collections.<ErrorPage>emptySet());
	// and the context path
	container.setContextPath("");
	// and add the management-specific bits
	container.setPort(this.managementServerProperties.getPort());
	if (this.managementServerProperties.getSsl() != null) {
		container.setSsl(this.managementServerProperties.getSsl());
	}
	container.setServerHeader(this.server.getServerHeader());
	container.setAddress(this.managementServerProperties.getAddress());
	container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:26,代码来源:EndpointWebMvcChildContextConfiguration.java

示例3: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);

    /*
     * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
     * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
     * See the JHipsterProperties class and your application-*.yml configuration files
     * for more information.
     */
    if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
        container instanceof UndertowEmbeddedServletContainerFactory) {

        ((UndertowEmbeddedServletContainerFactory) container)
            .addBuilderCustomizers(builder ->
                builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
    }
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:27,代码来源:WebConfigurer.java

示例4: cookieProcessorCustomizer

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

示例5: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    logger.info("Customizing EmbeddedServlet");

    Integer serverPort;
    { // setup the server port using the env vars
        String engineServerPortString = System.getenv().get(ENGINE_SERVER_PORT_KEY);
        if (engineServerPortString == null) {
            logger.error("FAILED to find env var [{}], will use defaults for engine server port", ENGINE_SERVER_PORT_KEY);
            serverPort = defaultServerPort;
        } else {
            logger.info("FOUND env var [{}], will use for engine server port", ENGINE_SERVER_PORT_KEY);
            serverPort = Integer.parseInt(engineServerPortString);
        }
    }

    logger.info("setting serverPort[{}]", serverPort);
    container.setPort(serverPort);
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:20,代码来源:CustomizationBean.java

示例6: containerCustomizer

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Bean
    public EmbeddedServletContainerCustomizer containerCustomizer() {
        return new EmbeddedServletContainerCustomizer() {
            @Override
            public void customize(ConfigurableEmbeddedServletContainer container) {
                ErrorPage page404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404");
                container.addErrorPages(page404);
            }
        };
//        return (container -> {
//            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
//            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
//            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
//
//            container.addErrorPages(error401Page, error404Page, error500Page);
//        });
    }
 
开发者ID:baidao,项目名称:tinker-manager,代码行数:18,代码来源:WebAppConfig.java

示例7: embeddedServletContainerCustomizer

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

示例8: embeddedServletContainerCustomizer

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

示例9: servletContainerCustomizer

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

示例10: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);

    // When running in an IDE or with ./gradlew bootRun, set location of the static web assets.
    File root;
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) {
        root = new File("build/www/");
    } else {
        root = new File("src/main/webapp/");
    }
    if (root.exists() && root.isDirectory()) {
        container.setDocumentRoot(root);
    }
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:24,代码来源:WebConfigurer.java

示例11: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
 * Set up Mime types and, if needed, set the document root.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
    // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
    mappings.add("html", "text/html;charset=utf-8");
    // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
    mappings.add("json", "text/html;charset=utf-8");
    container.setMimeMappings(mappings);<% if (!skipClient) { %>

    // When running in an IDE or with <% if (buildTool == 'gradle') { %>./gradlew bootRun<% } else { %>./mvnw spring-boot:run<% } %>, set location of the static web assets.
    File root;
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) {
        root = new File("<%= CLIENT_DIST_DIR %>");
    } else {
        root = new File("<%= CLIENT_MAIN_SRC_DIR %>");
    }
    if (root.exists() && root.isDirectory()) {
        container.setDocumentRoot(root);
    }<% } %>
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:24,代码来源:_WebConfigurer.java

示例12: containerCustomizer

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

示例13: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    KeystoreConfig cert = configureKeystore();
    if(cert == null) {
        log.debug("Ssl is not enabled due to no any configured keystore.");
        return;
    }
    String keystorePath = cert.getKeystore().getAbsolutePath();
    log.debug("Configure ssl with {} keystore.", keystorePath);
    Ssl ssl = new Ssl();
    ssl.setEnabled(true);
    ssl.setKeyStore(keystorePath);
    ssl.setKeyStorePassword(cert.getKeystorePassword());
    ssl.setKeyPassword(cert.getKeyPassword());
    container.setSsl(ssl);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:17,代码来源:SslServletContainerCustomizer.java

示例14: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
/**
 * Customize the Servlet engine: Mime types, the document root, the cache.
 */
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
	// IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
	mappings.add("html", "text/html;charset=utf-8");
	// CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
	mappings.add("json", "text/html;charset=utf-8");
	container.setMimeMappings(mappings);
	// When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
	setLocationForStaticAssets(container);

       /*
        * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
        * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
        * See the JHipsterProperties class and your application-*.yml configuration files
        * for more information.
        */
	if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
		container instanceof UndertowEmbeddedServletContainerFactory) {

		((UndertowEmbeddedServletContainerFactory) container)
			.addBuilderCustomizers(builder ->
				builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
	}
}
 
开发者ID:alikemalocalan,项目名称:MicroBlog,代码行数:29,代码来源:WebConfigurer.java

示例15: customize

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; //导入依赖的package包/类
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
	if (this.managementServerProperties == null) {
		this.managementServerProperties = BeanFactoryUtils
				.beanOfTypeIncludingAncestors(this.beanFactory,
						ManagementServerProperties.class);
		this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
				this.beanFactory, ServerProperties.class);
	}
	// Customize as per the parent context first (so e.g. the access logs go to
	// the same place)
	this.server.customize(container);
	// Then reset the error pages
	container.setErrorPages(Collections.<ErrorPage>emptySet());
	// and the context path
	container.setContextPath("");
	// and add the management-specific bits
	container.setPort(this.managementServerProperties.getPort());
	container.setServerHeader(this.server.getServerHeader());
	container.setAddress(this.managementServerProperties.getAddress());
	container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:23,代码来源:EndpointWebMvcChildContextConfiguration.java


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