All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.litongjava.tio.boot.spring.EmbeddedTioBoot Maven / Gradle / Ivy

There is a newer version: 1.8.6
Show newest version
package com.litongjava.tio.boot.spring;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.litongjava.tio.boot.server.TioBootServer;

@Configuration()
@ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({ TioBootServer.class })
public class EmbeddedTioBoot {

  @Bean
  public TioBootReactiveWebServerFactory tioBootReactiveWebServerFactory(
      ObjectProvider routes, ObjectProvider serverCustomizers) {

    TioBootReactiveWebServerFactory serverFactory = new TioBootReactiveWebServerFactory();
    //serverFactory.setResourceFactory(resourceFactory);
    routes.orderedStream().forEach(serverFactory::addRouteProviders);

    List collect = serverCustomizers.orderedStream().collect(Collectors.toList());
    serverFactory.getServerCustomizers().addAll(collect);
    return serverFactory;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy