Exemplo n.º 1
0
 private void customizeConnectionTimeout(
     TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) {
   for (Connector connector : factory.getAdditionalTomcatConnectors()) {
     if (connector.getProtocolHandler() instanceof AbstractProtocol) {
       AbstractProtocol<?> handler = (AbstractProtocol<?>) connector.getProtocolHandler();
       handler.setConnectionTimeout(connectionTimeout);
     }
   }
 }
Exemplo n.º 2
0
  @Bean
  public EmbeddedServletContainerFactory servletContainer() {
    final TomcatEmbeddedServletContainerFactory tomcat =
        new TomcatEmbeddedServletContainerFactory();

    if (casProperties.getServer().getAjp().isEnabled()) {
      final Connector ajpConnector =
          new Connector(casProperties.getServer().getAjp().getProtocol());
      ajpConnector.setProtocol(casProperties.getServer().getAjp().getProtocol());
      ajpConnector.setPort(casProperties.getServer().getAjp().getPort());
      ajpConnector.setSecure(casProperties.getServer().getAjp().isSecure());
      ajpConnector.setAllowTrace(casProperties.getServer().getAjp().isAllowTrace());
      ajpConnector.setScheme(casProperties.getServer().getAjp().getScheme());
      ajpConnector.setAsyncTimeout(casProperties.getServer().getAjp().getAsyncTimeout());
      ajpConnector.setEnableLookups(casProperties.getServer().getAjp().isEnableLookups());
      ajpConnector.setMaxPostSize(casProperties.getServer().getAjp().getMaxPostSize());

      if (casProperties.getServer().getAjp().getProxyPort() > 0) {
        ajpConnector.setProxyPort(casProperties.getServer().getAjp().getProxyPort());
      }

      if (casProperties.getServer().getAjp().getRedirectPort() > 0) {
        ajpConnector.setRedirectPort(casProperties.getServer().getAjp().getRedirectPort());
      }
      tomcat.addAdditionalTomcatConnectors(ajpConnector);
    }

    if (casProperties.getServer().getHttp().isEnabled()) {
      final Connector connector = new Connector(casProperties.getServer().getHttp().getProtocol());

      int port = casProperties.getServer().getHttp().getPort();
      if (port <= 0) {
        port = SocketUtils.findAvailableTcpPort();
      }
      connector.setPort(port);
      tomcat.addAdditionalTomcatConnectors(connector);
    }

    tomcat
        .getAdditionalTomcatConnectors()
        .stream()
        .filter(connector -> connector.getProtocolHandler() instanceof AbstractProtocol)
        .forEach(
            connector -> {
              final AbstractProtocol handler = (AbstractProtocol) connector.getProtocolHandler();
              handler.setSoTimeout(casProperties.getServer().getConnectionTimeout());
              handler.setConnectionTimeout(casProperties.getServer().getConnectionTimeout());
            });
    return tomcat;
  }
 @Override
 public void start() throws Exception {
   super.start();
   spdyContext = new SpdyContext();
   spdyContext.setTlsComprression(false, false);
   spdyContext.setHandler(
       new SpdyHandler() {
         @Override
         public void onStream(SpdyConnection con, SpdyStream ch) throws IOException {
           SpdyProcessor sp = new SpdyProcessor(con, endpoint);
           sp.setAdapter(getAdapter());
           sp.onSynStream(ch);
         }
       });
   spdyContext.setNetSupport(new NetSupportSocket());
   spdyContext.setExecutor(endpoint.getExecutor());
 }
Exemplo n.º 4
0
 private void customizeProtocol(AbstractProtocol<?> protocol) {
   if (getAddress() != null) {
     protocol.setAddress(getAddress());
   }
 }