Skip to content

Commit bec1c8f

Browse files
author
Phillip Webb
committed
Polish
1 parent d784cb6 commit bec1c8f

File tree

14 files changed

+104
-112
lines changed

14 files changed

+104
-112
lines changed

Diff for: spring-boot-cli/samples/book.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class Book {
2-
String author
3-
String title
4-
}
2+
String author
3+
String title
4+
}

Diff for: spring-boot-cli/samples/book_and_tests.groovy

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Book {
2-
String author
3-
String title
2+
String author
3+
String title
44
}
55

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

Diff for: spring-boot-cli/samples/failures.groovy

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@ class FailingSpockTest extends Specification {
3333
//throw new RuntimeException("This should fail!")
3434
true == false
3535
}
36-
37-
}
36+
}

Diff for: spring-boot-cli/samples/jms.groovy

+4-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ class JmsExample implements CommandLineRunner {
3434
jmsTemplate.send("spring-boot", messageCreator)
3535
latch.await()
3636
}
37-
3837
}
3938

4039
@Log
4140
class Receiver {
4241
CountDownLatch latch
43-
44-
def receive(String message) {
45-
log.info "Received ${message}"
46-
latch.countDown()
47-
}
42+
def receive(String message) {
43+
log.info "Received ${message}"
44+
latch.countDown()
45+
}
4846
}

Diff for: spring-boot-cli/samples/job.groovy

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class JobConfig {
1313

1414
@Bean
1515
protected Tasklet tasklet() {
16-
return new Tasklet() {
17-
@Override
18-
RepeatStatus execute(StepContribution contribution, ChunkContext context) {
19-
return RepeatStatus.FINISHED
20-
}
21-
}
16+
return new Tasklet() {
17+
@Override
18+
RepeatStatus execute(StepContribution contribution, ChunkContext context) {
19+
return RepeatStatus.FINISHED
20+
}
21+
}
2222
}
2323

2424
@Bean
@@ -31,5 +31,3 @@ class JobConfig {
3131
return steps.get("step1").tasklet(tasklet()).build()
3232
}
3333
}
34-
35-

Diff for: spring-boot-cli/samples/rabbit.groovy

+48-49
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,57 @@ import java.util.concurrent.CountDownLatch
77
@EnableRabbitMessaging
88
class RabbitExample implements CommandLineRunner {
99

10-
private CountDownLatch latch = new CountDownLatch(1)
11-
12-
@Autowired
13-
RabbitTemplate rabbitTemplate
14-
15-
private String queueName = "spring-boot"
16-
17-
@Bean
18-
Queue queue() {
19-
new Queue(queueName, false)
20-
}
21-
22-
@Bean
23-
TopicExchange exchange() {
24-
new TopicExchange("spring-boot-exchange")
25-
}
26-
27-
/**
28-
* The queue and topic exchange cannot be inlined inside this method and have
29-
* dynamic creation with Spring AMQP work properly.
30-
*/
31-
@Bean
32-
Binding binding(Queue queue, TopicExchange exchange) {
33-
BindingBuilder
34-
.bind(queue)
35-
.to(exchange)
36-
.with("spring-boot")
37-
}
38-
39-
@Bean
40-
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) {
41-
return new SimpleMessageListenerContainer(
42-
connectionFactory: connectionFactory,
43-
queueNames: [queueName],
44-
messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive")
45-
)
46-
}
47-
48-
void run(String... args) {
49-
log.info "Sending RabbitMQ message..."
50-
rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ")
51-
latch.await()
52-
}
53-
10+
private CountDownLatch latch = new CountDownLatch(1)
11+
12+
@Autowired
13+
RabbitTemplate rabbitTemplate
14+
15+
private String queueName = "spring-boot"
16+
17+
@Bean
18+
Queue queue() {
19+
new Queue(queueName, false)
20+
}
21+
22+
@Bean
23+
TopicExchange exchange() {
24+
new TopicExchange("spring-boot-exchange")
25+
}
26+
27+
/**
28+
* The queue and topic exchange cannot be inlined inside this method and have
29+
* dynamic creation with Spring AMQP work properly.
30+
*/
31+
@Bean
32+
Binding binding(Queue queue, TopicExchange exchange) {
33+
BindingBuilder
34+
.bind(queue)
35+
.to(exchange)
36+
.with("spring-boot")
37+
}
38+
39+
@Bean
40+
SimpleMessageListenerContainer container(CachingConnectionFactory connectionFactory) {
41+
return new SimpleMessageListenerContainer(
42+
connectionFactory: connectionFactory,
43+
queueNames: [queueName],
44+
messageListener: new MessageListenerAdapter(new Receiver(latch:latch), "receive")
45+
)
46+
}
47+
48+
void run(String... args) {
49+
log.info "Sending RabbitMQ message..."
50+
rabbitTemplate.convertAndSend(queueName, "Greetings from Spring Boot via RabbitMQ")
51+
latch.await()
52+
}
5453
}
5554

5655
@Log
5756
class Receiver {
58-
CountDownLatch latch
57+
CountDownLatch latch
5958

60-
def receive(String message) {
61-
log.info "Received ${message}"
62-
latch.countDown()
63-
}
59+
def receive(String message) {
60+
log.info "Received ${message}"
61+
latch.countDown()
62+
}
6463
}

Diff for: spring-boot-cli/samples/reactor.groovy

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import java.util.concurrent.CountDownLatch;
55
@EnableReactor
66
@Log
77
class Runner implements CommandLineRunner {
8-
8+
99
@Autowired
1010
Reactor reactor
11-
11+
1212
private CountDownLatch latch = new CountDownLatch(1)
13-
13+
1414
@PostConstruct
1515
void init() {
1616
log.info "Registering consumer"
@@ -21,12 +21,10 @@ class Runner implements CommandLineRunner {
2121
log.info "Notified Phil"
2222
latch.await()
2323
}
24-
24+
2525
@Selector(reactor="reactor", value="hello")
2626
void receive(String data) {
2727
log.info "Hello ${data}"
2828
latch.countDown()
29-
}
29+
}
3030
}
31-
32-

Diff for: spring-boot-cli/samples/runner.groovy

-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ class Runner implements CommandLineRunner {
66
print "Hello World!"
77
}
88
}
9-
10-

Diff for: spring-boot-cli/samples/spock.groovy

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class HelloSpock extends Specification {
2-
def "length of Spock's and his friends' names"() {
3-
expect:
4-
name.size() == length
2+
def "length of Spock's and his friends' names"() {
3+
expect:
4+
name.size() == length
55

6-
where:
7-
name | length
8-
"Spock" | 5
9-
"Kirk" | 4
10-
"Scotty" | 6
11-
}
12-
}
6+
where:
7+
name | length
8+
"Spock" | 5
9+
"Kirk" | 4
10+
"Scotty" | 6
11+
}
12+
}

Diff for: spring-boot-cli/samples/template.groovy

-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,3 @@ class MyService {
2121
return "World"
2222
}
2323
}
24-
25-

Diff for: spring-boot-cli/samples/test.groovy

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class BookTests {
2-
@Test
3-
void testBooks() {
4-
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
5-
assertEquals("Tom Clancy", book.author)
6-
}
7-
}
2+
@Test
3+
void testBooks() {
4+
Book book = new Book(author: "Tom Clancy", title: "Threat Vector")
5+
assertEquals("Tom Clancy", book.author)
6+
}
7+
}

Diff for: spring-boot-cli/samples/tx.groovy

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ package org.test
66
@EnableTransactionManagement
77
class Example implements CommandLineRunner {
88

9-
@Autowired
10-
JdbcTemplate jdbcTemplate
11-
12-
@Transactional
13-
void run(String... args) {
14-
println "Foo count=" + jdbcTemplate.queryForObject("SELECT COUNT(*) from FOO", Integer)
15-
}
9+
@Autowired
10+
JdbcTemplate jdbcTemplate
1611

12+
@Transactional
13+
void run(String... args) {
14+
println "Foo count=" + jdbcTemplate.queryForObject("SELECT COUNT(*) from FOO", Integer)
15+
}
1716
}
1817

Diff for: spring-boot-cli/samples/web.groovy

-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ class MyService {
1919
return "World!";
2020
}
2121
}
22-
23-

Diff for: spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java

+7
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@
6363
public class SpringApplicationBuilder {
6464

6565
private SpringApplication application;
66+
6667
private ConfigurableApplicationContext context;
68+
6769
private SpringApplicationBuilder parent;
70+
6871
private AtomicBoolean running = new AtomicBoolean(false);
72+
6973
private Set<Object> sources = new LinkedHashSet<Object>();
74+
7075
private Map<String, Object> defaultProperties = new LinkedHashMap<String, Object>();
76+
7177
private ConfigurableEnvironment environment;
78+
7279
private Set<String> additionalProfiles = new LinkedHashSet<String>();
7380
private Set<ApplicationContextInitializer<?>> initializers = new LinkedHashSet<ApplicationContextInitializer<?>>();
7481

0 commit comments

Comments
 (0)