Minimize and centralize assumptions about build output

Closes gh-15471
This commit is contained in:
Andy Wilkinson
2018-12-14 17:50:20 +00:00
parent 7d0a7a65c8
commit 61d04db0d7
57 changed files with 778 additions and 337 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 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.
@@ -16,21 +16,22 @@
package sample.integration;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Component
public class SampleCommandLineRunner implements CommandLineRunner {
public class SampleApplicationRunner implements ApplicationRunner {
private final SampleMessageGateway gateway;
public SampleCommandLineRunner(SampleMessageGateway gateway) {
public SampleApplicationRunner(SampleMessageGateway gateway) {
this.gateway = gateway;
}
@Override
public void run(String... args) throws Exception {
for (String arg : args) {
public void run(ApplicationArguments args) throws Exception {
for (String arg : args.getNonOptionArgs()) {
this.gateway.echo(arg);
}
}

View File

@@ -16,7 +16,6 @@
package sample.integration;
import java.io.File;
import java.util.function.Consumer;
import org.springframework.boot.SpringApplication;
@@ -35,10 +34,16 @@ import org.springframework.integration.file.FileWritingMessageHandler;
@EnableConfigurationProperties(ServiceProperties.class)
public class SampleIntegrationApplication {
private final ServiceProperties serviceProperties;
public SampleIntegrationApplication(ServiceProperties serviceProperties) {
this.serviceProperties = serviceProperties;
}
@Bean
public FileReadingMessageSource fileReader() {
FileReadingMessageSource reader = new FileReadingMessageSource();
reader.setDirectory(new File("target/input"));
reader.setDirectory(this.serviceProperties.getInputDir());
return reader;
}
@@ -55,7 +60,7 @@ public class SampleIntegrationApplication {
@Bean
public FileWritingMessageHandler fileWriter() {
FileWritingMessageHandler writer = new FileWritingMessageHandler(
new File("target/output"));
this.serviceProperties.getOutputDir());
writer.setExpectReply(false);
return writer;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2018 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.
@@ -16,6 +16,8 @@
package sample.integration;
import java.io.File;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
@@ -26,6 +28,10 @@ public class ServiceProperties {
private String greeting = "Hello";
private File inputDir;
private File outputDir;
@ManagedAttribute
public String getGreeting() {
return this.greeting;
@@ -35,4 +41,20 @@ public class ServiceProperties {
this.greeting = greeting;
}
public File getInputDir() {
return this.inputDir;
}
public void setInputDir(File inputDir) {
this.inputDir = inputDir;
}
public File getOutputDir() {
return this.outputDir;
}
public void setOutputDir(File outputDir) {
this.outputDir = outputDir;
}
}