From 384a01c6b32879e70e4bc448d06d11a941fd703f Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 23 Mar 2015 16:08:51 +0000 Subject: [PATCH] v0.52 release --- build.gradle | 4 +- micro-boot/build.gradle | 2 +- .../server/boot/config/MicrobootApp.java | 215 +++++++++--------- .../server/spring/boot/JerseyApplication.java | 9 - micro-core/build.gradle | 2 +- 5 files changed, 114 insertions(+), 118 deletions(-) diff --git a/build.gradle b/build.gradle index 57e54933f..4a4fe0cc7 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ subprojects { apply plugin: 'com.bmuschko.nexus' sourceCompatibility = 1.8 targetCompatibility = 1.8 - version = '0.51' + version = '0.52' jar { manifest { attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version @@ -45,7 +45,7 @@ subprojects { exclude(module: 'org.springframework') } compile 'net.javacrumbs.future-converter:future-converter-spring-java8:0.1.0' - compile group: 'com.aol.simplereact', name:'simple-react', version:'0.5' + compile group: 'com.aol.simplereact', name:'simple-react', version:'0.80' compile group: 'org.apache.httpcomponents', name:'httpclient', version:'4.4' compile group: 'org.apache.httpcomponents', name:'httpasyncclient', version:'4.1-beta1' compile group: 'com.wordnik', name: 'swagger-jersey2-jaxrs_2.10', version:'1.3.10' diff --git a/micro-boot/build.gradle b/micro-boot/build.gradle index e55f7a62d..653d702e9 100644 --- a/micro-boot/build.gradle +++ b/micro-boot/build.gradle @@ -18,7 +18,7 @@ modifyPom { groupId 'com.aol.microservices' artifactId 'microserver-boot' - version '0.51' + version '0.52' scm { url 'scm:git@github.com:aol/micro-server.git' diff --git a/micro-boot/src/main/java/com/aol/micro/server/boot/config/MicrobootApp.java b/micro-boot/src/main/java/com/aol/micro/server/boot/config/MicrobootApp.java index aa38833ae..5630967be 100644 --- a/micro-boot/src/main/java/com/aol/micro/server/boot/config/MicrobootApp.java +++ b/micro-boot/src/main/java/com/aol/micro/server/boot/config/MicrobootApp.java @@ -22,126 +22,131 @@ import com.aol.simple.react.exceptions.ExceptionSoftener; import com.google.common.collect.Lists; - public class MicrobootApp { - - - private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - private final List modules; - private final CompletableFuture end = new CompletableFuture(); - private final ExceptionSoftener softener = ExceptionSoftener.singleton.factory.getInstance(); - - @Getter - private final ApplicationContext springContext; - - /** - * This will construct a Spring context, using Spring Boot for this Microboot instance. - * The calling class will be used to determine the base package to auto-scan from for Spring Beans - * It will attempt to pick up an @Microservice annotation first, if not present the package of the calling class - * will be used. - * - * @param modules Multiple Microservice end points that can be deployed within a single Spring context - */ - public MicrobootApp(Module...modules){ - this.modules = Lists.newArrayList(modules); - springContext = new SpringContextFactory(new MicrobootConfigurator().buildConfig(extractClass()),extractClass(), - modules[0].getSpringConfigurationClasses()).withSpringBuilder(new BootApplicationConfigurator()).createSpringContext(); - - + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private final List modules; + private final CompletableFuture end = new CompletableFuture(); + private final ExceptionSoftener softener = ExceptionSoftener.singleton.factory + .getInstance(); + + @Getter + private final ApplicationContext springContext; + + /** + * This will construct a Spring context, using Spring Boot for this + * Microboot instance. The calling class will be used to determine the base + * package to auto-scan from for Spring Beans It will attempt to pick up an @Microservice + * annotation first, if not present the package of the calling class will be + * used. + * + * @param modules + * Multiple Microservice end points that can be deployed within a + * single Spring context + */ + public MicrobootApp(Module... modules) { + this.modules = Lists.newArrayList(modules); + springContext = new SpringContextFactory( + new MicrobootConfigurator().buildConfig(extractClass()), + extractClass(), modules[0].getSpringConfigurationClasses()) + .withSpringBuilder(new BootApplicationConfigurator()) + .createSpringContext(); + + } + + /** + * This will construct a Spring context, using Spring Boot for this + * Microboot instance. The provided class will be used to determine the base + * package to auto-scan from for Spring Beans It will attempt to pick up an @Microservice + * annotation first, if not present the package of the provided class will + * be used. + * + * @param c + * Class used to configure Spring + * @param modules + * Multiple Microservice end points that can be deployed within a + * single Spring context + */ + public MicrobootApp(Class c, Module... modules) { + + this.modules = Lists.newArrayList(modules); + springContext = new SpringContextFactory( + new MicrobootConfigurator().buildConfig(c), c, + modules[0].getSpringConfigurationClasses()).withSpringBuilder( + new BootApplicationConfigurator()).createSpringContext(); + + } + + /** + * This will construct a Spring context, using Spring Boot for this + * Microboot instance. The provided Config object will be used to configure + * Spring + * + * @param config + * Spring configuration + * @param modules + * Multiple Microservice end points that can be deployed within a + * single Spring context + */ + public MicrobootApp(Config config, Module... modules) { + + this.modules = Lists.newArrayList(modules); + config.set(); + springContext = new SpringContextFactory(config, + modules[0].getSpringConfigurationClasses()).withSpringBuilder( + new BootApplicationConfigurator()).createSpringContext(); + + } + + private Class extractClass() { + try { + return Class.forName(new Exception().getStackTrace()[2] + .getClassName()); + } catch (ClassNotFoundException e) { + softener.throwSoftenedException(e); } + return null; // unreachable normally + } - - /** - * This will construct a Spring context, using Spring Boot for this Microboot instance. - * The provided class will be used to determine the base package to auto-scan from for Spring Beans - * It will attempt to pick up an @Microservice annotation first, if not present the package of the provided class - * will be used. - * - * @param c Class used to configure Spring - * @param modules Multiple Microservice end points that can be deployed within a single Spring context - */ - public MicrobootApp(Class c, Module... modules) { - - this.modules = Lists.newArrayList(modules); - springContext =new SpringContextFactory(new MicrobootConfigurator().buildConfig(c),c, - modules[0].getSpringConfigurationClasses()).withSpringBuilder(new BootApplicationConfigurator()).createSpringContext(); - - } + public void stop() { - /** - * This will construct a Spring context, using Spring Boot for this Microboot instance. - * The provided Config object will be used to configure Spring - * - * @param config Spring configuration - * @param modules Multiple Microservice end points that can be deployed within a single Spring context - */ - public MicrobootApp(Config config, Module... modules) { - - this.modules = Lists.newArrayList(modules); - config.set(); - springContext = - new SpringContextFactory(config, - modules[0].getSpringConfigurationClasses()) - .withSpringBuilder(new BootApplicationConfigurator()) - .createSpringContext(); + end.complete(true); + Config.reset(); - } + } - - private Class extractClass() { - try { - return Class.forName(new Exception().getStackTrace()[2] - .getClassName()); - } catch (ClassNotFoundException e) { - softener.throwSoftenedException(e); - } - return null; // unreachable normally - } + public void run() { + start().forEach(thread -> join(thread)); + } - - public void stop() { + public List start() { - end.complete(true); - Config.reset(); + List apps = modules + .stream() + .map(module -> new GrizzlyApplicationFactory(springContext, + module).createApp()).collect(Collectors.toList()); - } + ServerRunner runner; + try { - public void run() { - start().forEach(thread -> join(thread)); + runner = new ServerRunner( + springContext.getBean(ApplicationRegister.class), apps, end); + } catch (BeansException e) { + runner = new ServerRunner(apps, end); } - public List start() { - - List apps = modules - .stream() - .map(module -> new GrizzlyApplicationFactory(springContext, - module).createApp()).collect(Collectors.toList()); - - ServerRunner runner; - try { + return runner.run(); - runner = new ServerRunner( - springContext.getBean(ApplicationRegister.class), apps, end); - } catch (BeansException e) { - runner = new ServerRunner(apps, end); - } + } - return runner.run(); - + private void join(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + softener.throwSoftenedException(e); } - - private void join(Thread thread) { - try { - thread.join(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - softener.throwSoftenedException(e); - } - } - - - + } } diff --git a/micro-boot/src/main/java/com/aol/micro/server/spring/boot/JerseyApplication.java b/micro-boot/src/main/java/com/aol/micro/server/spring/boot/JerseyApplication.java index 4294c89e1..fed06a126 100644 --- a/micro-boot/src/main/java/com/aol/micro/server/spring/boot/JerseyApplication.java +++ b/micro-boot/src/main/java/com/aol/micro/server/spring/boot/JerseyApplication.java @@ -67,16 +67,7 @@ public AccessLogLocationBean createAccessLogLocationBean( return new AccessLogLocationBean(location); } - @Bean - public Environment createEnvironment(ApplicationContext rootContext) { - Properties props = (Properties) rootContext.getBean("propertyFactory"); - Map moduleDefinitions = rootContext - .getBeansOfType(ModuleBean.class); - if (moduleDefinitions == null) - return new Environment(props); - return new Environment(props, moduleDefinitions.values()); - } public DAOProvider buildDAOProvider( AnnotationConfigWebApplicationContext rootContext, diff --git a/micro-core/build.gradle b/micro-core/build.gradle index fbcfd4a3a..0329b33ac 100644 --- a/micro-core/build.gradle +++ b/micro-core/build.gradle @@ -11,7 +11,7 @@ modifyPom { groupId 'com.aol.microservices' artifactId 'microserver-core' - version '0.51' + version '0.52' scm { url 'scm:git@github.com:aol/micro-server.git'