Browse Source

Polish

pull/118/merge
Phillip Webb 12 years ago
parent
commit
bec1c8f00f
  1. 6
      spring-boot-cli/samples/book.groovy
  2. 16
      spring-boot-cli/samples/book_and_tests.groovy
  3. 3
      spring-boot-cli/samples/failures.groovy
  4. 10
      spring-boot-cli/samples/jms.groovy
  5. 14
      spring-boot-cli/samples/job.groovy
  6. 97
      spring-boot-cli/samples/rabbit.groovy
  7. 12
      spring-boot-cli/samples/reactor.groovy
  8. 2
      spring-boot-cli/samples/runner.groovy
  9. 20
      spring-boot-cli/samples/spock.groovy
  10. 2
      spring-boot-cli/samples/template.groovy
  11. 12
      spring-boot-cli/samples/test.groovy
  12. 13
      spring-boot-cli/samples/tx.groovy
  13. 2
      spring-boot-cli/samples/web.groovy
  14. 7
      spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java

6
spring-boot-cli/samples/book.groovy

@ -1,4 +1,4 @@
class Book { class Book {
String author String author
String title String title
} }

16
spring-boot-cli/samples/book_and_tests.groovy

@ -1,12 +1,12 @@
class Book { class Book {
String author String author
String title String title
} }
class BookTests { class BookTests {
@Test @Test
void testBooks() { void testBooks() {
Book book = new Book(author: "Tom Clancy", title: "Threat Vector") Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
assertEquals("Tom Clancy", book.author) assertEquals("Tom Clancy", book.author)
} }
} }

3
spring-boot-cli/samples/failures.groovy

@ -33,5 +33,4 @@ class FailingSpockTest extends Specification {
//throw new RuntimeException("This should fail!") //throw new RuntimeException("This should fail!")
true == false true == false
} }
}
}

10
spring-boot-cli/samples/jms.groovy

@ -34,15 +34,13 @@ class JmsExample implements CommandLineRunner {
jmsTemplate.send("spring-boot", messageCreator) jmsTemplate.send("spring-boot", messageCreator)
latch.await() latch.await()
} }
} }
@Log @Log
class Receiver { class Receiver {
CountDownLatch latch CountDownLatch latch
def receive(String message) {
def receive(String message) { log.info "Received ${message}"
log.info "Received ${message}" latch.countDown()
latch.countDown() }
}
} }

14
spring-boot-cli/samples/job.groovy

@ -13,12 +13,12 @@ class JobConfig {
@Bean @Bean
protected Tasklet tasklet() { protected Tasklet tasklet() {
return new Tasklet() { return new Tasklet() {
@Override @Override
RepeatStatus execute(StepContribution contribution, ChunkContext context) { RepeatStatus execute(StepContribution contribution, ChunkContext context) {
return RepeatStatus.FINISHED return RepeatStatus.FINISHED
} }
} }
} }
@Bean @Bean
@ -31,5 +31,3 @@ class JobConfig {
return steps.get("step1").tasklet(tasklet()).build() return steps.get("step1").tasklet(tasklet()).build()
} }
} }

97
spring-boot-cli/samples/rabbit.groovy

@ -7,58 +7,57 @@ import java.util.concurrent.CountDownLatch
@EnableRabbitMessaging @EnableRabbitMessaging
class RabbitExample implements CommandLineRunner { class RabbitExample implements CommandLineRunner {
private CountDownLatch latch = new CountDownLatch(1) private CountDownLatch latch = new CountDownLatch(1)
@Autowired @Autowired
RabbitTemplate rabbitTemplate RabbitTemplate rabbitTemplate
private String queueName = "spring-boot" private String queueName = "spring-boot"
@Bean @Bean
Queue queue() { Queue queue() {
new Queue(queueName, false) new Queue(queueName, false)
} }
@Bean @Bean
TopicExchange exchange() { TopicExchange exchange() {
new TopicExchange("spring-boot-exchange") new TopicExchange("spring-boot-exchange")
} }
/** /**
* The queue and topic exchange cannot be inlined inside this method and have * The queue and topic exchange cannot be inlined inside this method and have
* dynamic creation with Spring AMQP work properly. * dynamic creation with Spring AMQP work properly.
*/ */
@Bean @Bean
Binding binding(Queue queue, TopicExchange exchange) { Binding binding(Queue queue, TopicExchange exchange) {
BindingBuilder BindingBuilder
.bind(queue) .bind(queue)
.to(exchange) .to(exchange)
.with("spring-boot") .with("spring-boot")
} }
@Bean @Bean
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) { SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) {
return new SimpleMessageListenerContainer( return new SimpleMessageListenerContainer(
connectionFactory: connectionFactory, connectionFactory: connectionFactory,
queueNames: [queueName], queueNames: [queueName],
messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive") messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive")
) )
} }
void run(String... args) { void run(String... args) {
log.info "Sending RabbitMQ message..." log.info "Sending RabbitMQ message..."
rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ") rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ")
latch.await() latch.await()
} }
} }
@Log @Log
class Receiver { class Receiver {
CountDownLatch latch CountDownLatch latch
def receive(String message) { def receive(String message) {
log.info "Received ${message}" log.info "Received ${message}"
latch.countDown() latch.countDown()
} }
} }

12
spring-boot-cli/samples/reactor.groovy

@ -5,12 +5,12 @@ import java.util.concurrent.CountDownLatch;
@EnableReactor @EnableReactor
@Log @Log
class Runner implements CommandLineRunner { class Runner implements CommandLineRunner {
@Autowired @Autowired
Reactor reactor Reactor reactor
private CountDownLatch latch = new CountDownLatch(1) private CountDownLatch latch = new CountDownLatch(1)
@PostConstruct @PostConstruct
void init() { void init() {
log.info "Registering consumer" log.info "Registering consumer"
@ -21,12 +21,10 @@ class Runner implements CommandLineRunner {
log.info "Notified Phil" log.info "Notified Phil"
latch.await() latch.await()
} }
@Selector(reactor="reactor", value="hello") @Selector(reactor="reactor", value="hello")
void receive(String data) { void receive(String data) {
log.info "Hello ${data}" log.info "Hello ${data}"
latch.countDown() latch.countDown()
} }
} }

2
spring-boot-cli/samples/runner.groovy

@ -6,5 +6,3 @@ class Runner implements CommandLineRunner {
print "Hello World!" print "Hello World!"
} }
} }

20
spring-boot-cli/samples/spock.groovy

@ -1,12 +1,12 @@
class HelloSpock extends Specification { class HelloSpock extends Specification {
def "length of Spock's and his friends' names"() { def "length of Spock's and his friends' names"() {
expect: expect:
name.size() == length name.size() == length
where: where:
name | length name | length
"Spock" | 5 "Spock" | 5
"Kirk" | 4 "Kirk" | 4
"Scotty" | 6 "Scotty" | 6
} }
} }

2
spring-boot-cli/samples/template.groovy

@ -21,5 +21,3 @@ class MyService {
return "World" return "World"
} }
} }

12
spring-boot-cli/samples/test.groovy

@ -1,7 +1,7 @@
class BookTests { class BookTests {
@Test @Test
void testBooks() { void testBooks() {
Book book = new Book(author: "Tom Clancy", title: "Threat Vector") Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
assertEquals("Tom Clancy", book.author) assertEquals("Tom Clancy", book.author)
} }
} }

13
spring-boot-cli/samples/tx.groovy

@ -6,13 +6,12 @@ package org.test
@EnableTransactionManagement @EnableTransactionManagement
class Example implements CommandLineRunner { class Example implements CommandLineRunner {
@Autowired @Autowired
JdbcTemplate jdbcTemplate JdbcTemplate jdbcTemplate
@Transactional
void run(String... args) {
println "Foo count=" + jdbcTemplate.queryForObject("SELECT COUNT(*) from FOO", Integer)
}
@Transactional
void run(String... args) {
println "Foo count=" + jdbcTemplate.queryForObject("SELECT COUNT(*) from FOO", Integer)
}
} }

2
spring-boot-cli/samples/web.groovy

@ -19,5 +19,3 @@ class MyService {
return "World!"; return "World!";
} }
} }

7
spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java

@ -63,12 +63,19 @@ import org.springframework.core.io.ResourceLoader;
public class SpringApplicationBuilder { public class SpringApplicationBuilder {
private SpringApplication application; private SpringApplication application;
private ConfigurableApplicationContext context; private ConfigurableApplicationContext context;
private SpringApplicationBuilder parent; private SpringApplicationBuilder parent;
private AtomicBoolean running = new AtomicBoolean(false); private AtomicBoolean running = new AtomicBoolean(false);
private Set<Object> sources = new LinkedHashSet<Object>(); private Set<Object> sources = new LinkedHashSet<Object>();
private Map<String, Object> defaultProperties = new LinkedHashMap<String, Object>(); private Map<String, Object> defaultProperties = new LinkedHashMap<String, Object>();
private ConfigurableEnvironment environment; private ConfigurableEnvironment environment;
private Set<String> additionalProfiles = new LinkedHashSet<String>(); private Set<String> additionalProfiles = new LinkedHashSet<String>();
private Set<ApplicationContextInitializer<?>> initializers = new LinkedHashSet<ApplicationContextInitializer<?>>(); private Set<ApplicationContextInitializer<?>> initializers = new LinkedHashSet<ApplicationContextInitializer<?>>();

Loading…
Cancel
Save