Java 类org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer 实例源码

项目:mxhsd    文件:MxhsdFederationApp.java   
@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;
}
项目:apollo-custom    文件:TomcatContainerCustomizer.java   
@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);
      }

    }
  });
}
项目:apollo    文件:TomcatContainerCustomizer.java   
@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);
      }

    }
  });
}
项目:metasfresh-webui-api    文件:WebRestApiApplication.java   
@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);
                }
            });
        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServerProperties.java   
@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);
            }
        }

    });
}
项目:findlunch    文件:Beans.java   
/**
 * 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
                              }
                        }
                  );
              }
          }
    };
  }
项目:spring-boot-concourse    文件:ServerProperties.java   
@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);
            }
        }

    });
}
项目:contestparser    文件:ServerProperties.java   
@SuppressWarnings("rawtypes")
private void customizeMaxHttpHeaderSize(
        TomcatEmbeddedServletContainerFactory factory) {
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

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

    });
}
项目:centromere    文件:WebServicesConfig.java   
@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer(){
    return configurableEmbeddedServletContainer -> 
            ((TomcatEmbeddedServletContainerFactory) configurableEmbeddedServletContainer).addConnectorCustomizers(
            new TomcatConnectorCustomizer() {
                @Override
                public void customize(Connector connector) {
                    AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler();
                    httpProtocol.setCompression("on");
                    httpProtocol.setCompressionMinSize(256);
                    String mimeTypes = httpProtocol.getCompressableMimeTypes();
                    String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE;
                    httpProtocol.setCompressableMimeTypes(mimeTypesWithJson);
                }
            }
    );
}
项目:booties    文件:ProxiesAutoConfiguration.java   
@Bean
public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() {

    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(final ConfigurableEmbeddedServletContainer container) {
            if (container instanceof TomcatEmbeddedServletContainerFactory) {
                TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
                for (TomcatConnectorCustomizer customizer : tomcatConnectorCustomizers) {
                    tomcat.addConnectorCustomizers(customizer);
                }
            }
        }
    };
}
项目:odo    文件:HomeController.java   
@Bean
public EmbeddedServletContainerFactory servletContainer() throws Exception {
    TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();

    int apiPort = Utils.getSystemPort(Constants.SYS_API_PORT);
    factory.setPort(apiPort);
    factory.setSessionTimeout(10, TimeUnit.MINUTES);
    factory.setContextPath("/testproxy");
    baseDirectory = new File("./tmp");
    factory.setBaseDirectory(baseDirectory);
    List<TomcatConnectorCustomizer> cs = new ArrayList();
    cs.add(tomcatConnectorCustomizers());
    factory.setTomcatConnectorCustomizers(cs);

    if (Utils.getEnvironmentOptionValue(Constants.SYS_LOGGING_DISABLED) != null) {
        HistoryService.getInstance().disableHistory();
    }
    return factory;
}
项目:mxhsd    文件:MxhsdClientApp.java   
@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();

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

    return tomcat;
}
项目:weixin_component    文件:MyazureEmbeddedServletContainerCustomizer.java   
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);
        }
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServerProperties.java   
@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);
            }

        }
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServerProperties.java   
@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);
            }

        }
    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ServerProperties.java   
private void customizeMaxHttpPostSize(
        TomcatEmbeddedServletContainerFactory factory,
        final int maxHttpPostSize) {
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

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

    });
}
项目:metasfresh-procurement-webui    文件:Application.java   
/**
 * 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());
                }
            });
        }
    };
}
项目:spring-boot-concourse    文件:ServerProperties.java   
@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);
            }

        }
    });
}
项目:spring-boot-concourse    文件:ServerProperties.java   
@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);
            }

        }
    });
}
项目:spring-boot-concourse    文件:ServerProperties.java   
private void customizeMaxHttpPostSize(
        TomcatEmbeddedServletContainerFactory factory,
        final int maxHttpPostSize) {
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

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

    });
}
项目:putput    文件:HttpsConfig.java   
@Bean
@Autowired
public EmbeddedServletContainerCustomizer containerCustomizer() {
  Boolean httpsEnabled = environment.getProperty(PutPutConfiguration.HTTPS_ENABLED, Boolean.class, false);

  String keystoreFile = environment.getProperty("keystore.file", "classpath:keystore.jks");
  String keystorePassword = environment.getProperty("keystore.password", "password");
  String keystoreType = environment.getProperty("keystore.type", "jks");
  String keystoreAlias = environment.getProperty("keystore.alias");

  return (ConfigurableEmbeddedServletContainer factory) -> {
    TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) factory;

    if (httpsEnabled) {
      final String absoluteKeystoreFile = getKeyStoreFilePath(keystoreFile);

      containerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) (Connector connector) -> {
        connector.setSecure(true);
        connector.setScheme("https");
        connector.setAttribute("keystoreFile", absoluteKeystoreFile);
        connector.setAttribute("keystorePass", keystorePassword);
        connector.setAttribute("keystoreType", keystoreType);

        if (keystoreAlias != null) {
          connector.setAttribute("keyAlias", keystoreAlias);
        }

        connector.setAttribute("clientAuth", "false");
        connector.setAttribute("sslProtocol", "TLS");
        connector.setAttribute("SSLEnabled", true);
      });
    }
  };
}
项目:contestparser    文件:ServerProperties.java   
@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);
            }

        }
    });
}
项目:Hammerhead-StatsCollector    文件:Application.java   
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() throws FileNotFoundException {
    final String absoluteKeystoreFile = ResourceUtils.getFile(keystoreFile).getAbsolutePath();

    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(final ConfigurableEmbeddedServletContainer factory) {
            if(factory instanceof TomcatEmbeddedServletContainerFactory) {
                TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) factory;
                containerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

                    @Override
                    public void customize(final Connector connector) {
                        connector.setPort(getPortNumber());
                        connector.setSecure(true);
                        connector.setScheme("https");
                        Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
                        proto.setSSLEnabled(true);
                        proto.setKeystoreFile(absoluteKeystoreFile);
                        proto.setKeystorePass(keystorePass);
                        proto.setKeystoreType("PKCS12");
                    }
                });
            }
        }
    };
}
项目:mobilecloud-15    文件:OAuth2SecurityConfiguration.java   
@Bean
  EmbeddedServletContainerCustomizer containerCustomizer(
          @Value("${keystore.file:src/main/resources/private/keystore}") String keystoreFile,
          @Value("${keystore.pass:changeit}") final String keystorePass) throws Exception {

// If you were going to reuse this class in another
// application, this is one of the key sections that you
// would want to change

      final String absoluteKeystoreFile = new File(keystoreFile).getAbsolutePath();

      return new EmbeddedServletContainerCustomizer () {

    @Override
    public void customize(ConfigurableEmbeddedServletContainer container) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(
                    new TomcatConnectorCustomizer() {
                        @Override
                        public void customize(Connector connector) {
                            connector.setPort(8443);
                            connector.setSecure(true);
                            connector.setScheme("https");

                            Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
                            proto.setSSLEnabled(true);
                            proto.setKeystoreFile(absoluteKeystoreFile);
                            proto.setKeystorePass(keystorePass);
                            proto.setKeystoreType("JKS");
                            proto.setKeyAlias("tomcat");
                        }
                    });

    }
      };
  }
项目:JSF-on-Spring-Boot    文件:Port80ServletContainerCustomizer.java   
public void customizeTomcat(TomcatEmbeddedServletContainerFactory factory) {
    factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
      @Override
      public void customize(Connector connector) {
          connector.setPort(80);
//        Object defaultMaxThreads = connector.getAttribute("maxThreads");
//        connector.getAttribute("javax.faces.CLIENT_WINDOW_MODE")
        connector.setAttribute("maxThreads", MAX_THREADS);
      }
    });
  }
项目:blog-non-blocking-rest-service-with-spring-mvc    文件:MyEmbeddedServletContainerCustomizer.java   
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);
        }
    });
}
项目:blog-non-blocking-rest-service-with-spring-mvc    文件:MyEmbeddedServletContainerCustomizer.java   
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);
        }
    });
}
项目:blog-reactive    文件:MyEmbeddedServletContainerCustomizer.java   
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);
        }
    });
}
项目:blog-reactive    文件:MyEmbeddedServletContainerCustomizer.java   
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);
        }
    });
}
项目:MLDS    文件:WebConfigurer.java   
@Bean
 @Profile("ssl")
 EmbeddedServletContainerCustomizer containerCustomizer(
         @Value("${keystore.file}") Resource keystoreFile,
         @Value("${keystore.pass}") final String keystorePass) throws Exception {
     final String absoluteKeystoreFile = keystoreFile.getFile().getAbsolutePath();

     log.info("Web application configuration, SSL keystore: {}", absoluteKeystoreFile);

     return new EmbeddedServletContainerCustomizer() {

@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
         TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
         tomcat.addConnectorCustomizers(
             new TomcatConnectorCustomizer() {
        @Override
        public void customize(Connector connector) {
                  connector.setPort(8443);
                  connector.setSecure(true);
                  connector.setScheme("https");

                  Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
                  proto.setSSLEnabled(true);
                  proto.setKeystoreFile(absoluteKeystoreFile);
                  proto.setKeystorePass(keystorePass);
                  //proto.setKeystoreType("jks");
                  //proto.setKeyAlias("tomcat");
        }
             });
}
     };
 }
项目:mobilecloud-15    文件:Application.java   
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
        @Value("${keystore.file}") String keystoreFile,
        @Value("${keystore.pass}") final String keystorePass)
        throws Exception {


    // This is boiler plate code to setup https on embedded Tomcat
    // with Spring Boot:

    final String absoluteKeystoreFile = new File(keystoreFile)
            .getAbsolutePath();

    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() {

                @Override
                public void customize(Connector connector) {
                    connector.setPort(8443);
                    connector.setSecure(true);
                    connector.setScheme("https");

                    Http11NioProtocol proto = (Http11NioProtocol) connector
                            .getProtocolHandler();
                    proto.setSSLEnabled(true);

                    // If you update the keystore, you need to change
                    // these parameters to match the keystore that you generate
                    proto.setKeystoreFile(absoluteKeystoreFile);
                    proto.setKeystorePass(keystorePass);
                    proto.setKeystoreType("JKS");
                    proto.setKeyAlias("tomcat");

                }
            });
        }

    };
}
项目:mobilecloud-15    文件:Application.java   
@Bean
EmbeddedServletContainerCustomizer containerCustomizer(
        @Value("${keystore.file}") String keystoreFile,
        @Value("${keystore.pass}") final String keystorePass)
        throws Exception {


    // This is boiler plate code to setup https on embedded Tomcat
    // with Spring Boot:

    final String absoluteKeystoreFile = new File(keystoreFile)
            .getAbsolutePath();

    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
            tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() {

                @Override
                public void customize(Connector connector) {
                    connector.setPort(8443);
                    connector.setSecure(true);
                    connector.setScheme("https");

                    Http11NioProtocol proto = (Http11NioProtocol) connector
                            .getProtocolHandler();
                    proto.setSSLEnabled(true);

                    // If you update the keystore, you need to change
                    // these parameters to match the keystore that you generate
                    proto.setKeystoreFile(absoluteKeystoreFile);
                    proto.setKeystorePass(keystorePass);
                    proto.setKeystoreType("JKS");
                    proto.setKeyAlias("tomcat");

                }
            });
        }

    };
}
项目:odo    文件:HomeController.java   
@Bean
public TomcatConnectorCustomizer tomcatConnectorCustomizers() {
    return connector -> {
        connector.setMaxPostSize(-1);
    };
}
项目:magpie    文件:OAuth2SecurityConfiguration.java   
@Bean
EmbeddedServletContainerCustomizer containerCostumizer(
        @Value("${keystore.file:src/main/resources/private/keystore}") String keystoreFile,
        @Value("${keystore.pass:changeit}") final String keystorePass) throws Exception {

    final String absoluteKeyStore = new File(keystoreFile).getAbsolutePath();

    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            TomcatEmbeddedServletContainerFactory tomcat = null;
            boolean casted = true;
            try {
                tomcat = (TomcatEmbeddedServletContainerFactory) container;
            } catch(ClassCastException ex) {
                casted = false;
            }

            if (casted) {
                tomcat.addConnectorCustomizers(
                        new TomcatConnectorCustomizer() {
                            @Override
                            public void customize(Connector connector) {
                                connector.setPort(8443);
                                connector.setSecure(true);
                                connector.setScheme("https");

                                Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler();
                                proto.setSSLEnabled(true);
                                proto.setKeystoreFile(absoluteKeyStore);
                                proto.setKeystorePass(keystorePass);
                                proto.setKeystoreType("JKS");
                                proto.setKeyAlias("tomcat");
                            }
                        });
            } else {
                tomcat = new TomcatEmbeddedServletContainerFactory();
                tomcat.addAdditionalTomcatConnectors(createSSLConnector(absoluteKeyStore, keystorePass));
            }
        }
    };
}