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