Commit ee7c86a0 authored by Andy Wilkinson's avatar Andy Wilkinson

Start building against Reactor 2.0.1 snapshots

See gh-2719
parent 681894a1
......@@ -80,6 +80,11 @@
<artifactId>cache-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.projectreactor.spring</groupId>
<artifactId>reactor-spring-context</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
......@@ -415,11 +420,6 @@
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectreactor.spring</groupId>
<artifactId>reactor-spring-context</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms-api</artifactId>
......
......@@ -24,8 +24,8 @@ import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.Environment;
import reactor.core.Reactor;
import reactor.Environment;
import reactor.bus.EventBus;
import reactor.spring.context.config.EnableReactor;
/**
......@@ -39,15 +39,16 @@ import reactor.spring.context.config.EnableReactor;
public class ReactorAutoConfiguration {
@Bean
@ConditionalOnMissingBean(Reactor.class)
public Reactor rootReactor(Environment environment) {
return environment.getRootReactor();
@ConditionalOnMissingBean(EventBus.class)
public EventBus eventBus(Environment environment) {
return EventBus.create(environment);
}
@Configuration
@ConditionalOnMissingBean(Environment.class)
@EnableReactor
protected static class ReactorConfiguration {
}
}
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -21,43 +21,53 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.Environment;
import reactor.core.Reactor;
import reactor.core.spec.Reactors;
import reactor.bus.EventBus;
import reactor.core.Dispatcher;
import reactor.core.dispatch.MpscDispatcher;
import reactor.core.dispatch.RingBufferDispatcher;
import static org.junit.Assert.assertNotNull;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertThat;
/**
* Tests for {@link ReactorAutoConfiguration}.
*
* @author Dave Syer
* @author Andy Wilkinson
*/
public class ReactorAutoConfigurationTests {
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Test
public void reactorIsAvailable() {
public void eventBusIsAvailable() {
this.context.register(ReactorAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(Reactor.class));
EventBus eventBus = this.context.getBean(EventBus.class);
assertThat(eventBus.getDispatcher(), instanceOf(RingBufferDispatcher.class));
this.context.close();
}
@Test
public void customReactor() {
public void customEventBus() {
this.context.register(TestConfiguration.class, ReactorAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(Reactor.class));
EventBus eventBus = this.context.getBean(EventBus.class);
assertThat(eventBus.getDispatcher(), instanceOf(MpscDispatcher.class));
this.context.close();
}
@Configuration
protected static class TestConfiguration {
@Bean(destroyMethod = "shutdown")
public Dispatcher dispatcher() {
return new MpscDispatcher("test");
}
@Bean
public Reactor reactor(Environment env) {
return Reactors.reactor().env(env).dispatcher(Environment.RING_BUFFER).get();
public EventBus customEventBus() {
return EventBus.create(dispatcher());
}
}
......
......@@ -7,7 +7,7 @@ import java.util.concurrent.CountDownLatch
class Runner implements CommandLineRunner {
@Autowired
Reactor reactor
EventBus eventBus
private CountDownLatch latch = new CountDownLatch(1)
......@@ -17,7 +17,7 @@ class Runner implements CommandLineRunner {
}
void run(String... args) {
reactor.notify("hello", Event.wrap("Phil"))
eventBus.notify("hello", Event.wrap("Phil"))
log.info "Notified Phil"
latch.await()
}
......@@ -34,7 +34,7 @@ class Runner implements CommandLineRunner {
class Greeter {
@Autowired
Reactor reactor
EventBus eventBus
@Autowired
private CountDownLatch latch
......
......@@ -32,29 +32,28 @@ public class ReactorCompilerAutoConfiguration extends CompilerAutoConfiguration
@Override
public boolean matches(ClassNode classNode) {
return AstUtils.hasAtLeastOneAnnotation(classNode, "EnableReactor")
|| AstUtils.hasAtLeastOneFieldOrMethod(classNode, "Reactor");
|| AstUtils.hasAtLeastOneFieldOrMethod(classNode, "EventBus");
}
@Override
public void applyDependencies(DependencyCustomizer dependencies) {
dependencies.ifAnyMissingClasses("reactor.core.Reactor")
dependencies.ifAnyMissingClasses("reactor.bus.EventBus")
.add("reactor-spring-context", false).add("reactor-spring-core", false)
.add("reactor-core");
.add("reactor-bus").add("reactor-stream");
}
@Override
public void applyImports(ImportCustomizer imports) {
imports.addImports("reactor.core.Reactor", "reactor.core.spec.Reactors",
"reactor.core.Observable", "reactor.event.Event",
"reactor.function.Functions", "reactor.function.Predicates",
"reactor.function.Suppliers",
"reactor.spring.context.annotation.Consumer",
imports.addImports("reactor.bus.Bus", "reactor.bus.Event",
"reactor.bus.EventBus", "reactor.fn.Function", "reactor.fn.Functions",
"reactor.fn.Predicate", "reactor.fn.Predicates", "reactor.fn.Supplier",
"reactor.fn.Suppliers", "reactor.spring.context.annotation.Consumer",
"reactor.spring.context.annotation.ReplyTo",
"reactor.spring.context.annotation.Selector",
"reactor.spring.context.annotation.SelectorType",
"reactor.spring.context.annotation.ReplyTo",
"reactor.spring.context.config.EnableReactor")
.addStarImports("reactor.event.selector.Selectors")
.addImport("ReactorEnvironment", "reactor.core.Environment");
.addStarImports("reactor.bus.selector.Selectors")
.addImport("ReactorEnvironment", "reactor.Environment");
}
}
......@@ -3,11 +3,11 @@
class RestTests {
@Autowired
Reactor reactor
EventBus eventBus
@Test
void test() {
assertNotNull(reactor)
assertNotNull(eventBus)
}
}
......@@ -110,8 +110,8 @@
<mysql.version>5.1.34</mysql.version>
<nekohtml.version>1.9.21</nekohtml.version>
<postgresql.version>9.4-1201-jdbc41</postgresql.version>
<reactor.version>1.1.6.RELEASE</reactor.version>
<reactor-spring.version>1.1.3.RELEASE</reactor-spring.version>
<reactor.version>2.0.1.BUILD-SNAPSHOT</reactor.version>
<reactor-spring.version>2.0.1.BUILD-SNAPSHOT</reactor-spring.version>
<sendgrid.version>2.1.0</sendgrid.version>
<servlet-api.version>3.1.0</servlet-api.version>
<simple-json.version>1.1.1</simple-json.version>
......@@ -624,6 +624,61 @@
<artifactId>metrics-servlets</artifactId>
<version>${dropwizard-metrics.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-bus</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-groovy</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-groovy-extensions</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-logback</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-net</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-stream</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.spring</groupId>
<artifactId>reactor-spring-context</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.spring</groupId>
<artifactId>reactor-spring-core</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.spring</groupId>
<artifactId>reactor-spring-messaging</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.spring</groupId>
<artifactId>reactor-spring-webmvc</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
......@@ -1250,51 +1305,6 @@
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-groovy</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-groovy-extensions</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-logback</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor</groupId>
<artifactId>reactor-net</artifactId>
<version>${reactor.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor.spring</groupId>
<artifactId>reactor-spring-context</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor.spring</groupId>
<artifactId>reactor-spring-core</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor.spring</groupId>
<artifactId>reactor-spring-messaging</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>org.projectreactor.spring</groupId>
<artifactId>reactor-spring-webmvc</artifactId>
<version>${reactor-spring.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment