com.oath.micro.server.spring.boot.BootApplicationConfigurator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro-boot Show documentation
Show all versions of micro-boot Show documentation
Opinionated rest microservices with Spring Boot
package com.oath.micro.server.spring.boot;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import cyclops.reactive.ReactiveSeq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import com.oath.micro.server.config.Config;
import com.oath.micro.server.spring.SpringBuilder;
public class BootApplicationConfigurator implements SpringBuilder {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
public ConfigurableApplicationContext createSpringApp(Config config, Class...classes) {
List classList = new ArrayList();
classList.addAll(Arrays.asList(classes));
classList.add(JerseyApplication.class);
SpringApplicationBuilder builder = new SpringApplicationBuilder(classList.toArray(new Class[0]));
new JerseyApplication(classList).config(builder);
return builder.application().run();
}
@Override
public Class[] classes(Config config, Class... classes) {
List classList = new ArrayList();
classList.addAll(Arrays.asList(classes));
return ReactiveSeq.fromIterable(new JerseyApplication(classList).classes).appendAll(classList)
.toArray(i->new Class[i]);
}
}