Skip to content

Commit 2f06488

Browse files
authored
Merge pull request #190 from jacomago/autoformatter
Autoformatter
2 parents e7d7553 + d08f1ba commit 2f06488

File tree

76 files changed

+20109
-16986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+20109
-16986
lines changed

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@
229229
<artifactId>maven-surefire-plugin</artifactId>
230230
<version>3.1.2</version>
231231
</plugin>
232+
<plugin>
233+
<groupId>com.spotify.fmt</groupId>
234+
<artifactId>fmt-maven-plugin</artifactId>
235+
<version>2.23</version>
236+
<configuration>
237+
<filesNamePattern>.*\.java</filesNamePattern>
238+
<skipSortingImports>false</skipSortingImports>
239+
<style>google</style>
240+
</configuration>
241+
<executions>
242+
<execution>
243+
<id>formatter</id>
244+
<goals>
245+
<goal>format</goal>
246+
<goal>check</goal>
247+
</goals>
248+
</execution>
249+
</executions>
250+
</plugin>
232251
<!-- use self-contained integration tests - org.phoebus.channelfinder.docker -->
233252
<plugin>
234253
<groupId>org.apache.maven.plugins</groupId>

src/main/java/org/phoebus/channelfinder/Application.java

Lines changed: 79 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
package org.phoebus.channelfinder;
1212

13+
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
14+
import io.swagger.v3.oas.annotations.servers.Server;
1315
import java.io.File;
1416
import java.io.FileOutputStream;
1517
import java.io.IOException;
@@ -19,9 +21,6 @@
1921
import java.util.ServiceLoader;
2022
import java.util.logging.Level;
2123
import java.util.logging.Logger;
22-
23-
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
24-
import io.swagger.v3.oas.annotations.servers.Server;
2524
import org.phoebus.channelfinder.example.PopulateService;
2625
import org.phoebus.channelfinder.processors.ChannelProcessor;
2726
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,95 +37,95 @@
3837
import org.springframework.util.FileCopyUtils;
3938

4039
@EnableAutoConfiguration
41-
@ComponentScan(basePackages="org.phoebus.channelfinder")
40+
@ComponentScan(basePackages = "org.phoebus.channelfinder")
4241
@EnableScheduling
43-
@OpenAPIDefinition(
44-
servers = {
45-
@Server(url = "/")
46-
}
47-
)
42+
@OpenAPIDefinition(servers = {@Server(url = "/")})
4843
@SpringBootApplication
4944
public class Application implements ApplicationRunner {
5045

51-
static final Logger logger = Logger.getLogger(Application.class.getName());
46+
static final Logger logger = Logger.getLogger(Application.class.getName());
5247

53-
public static void main(String[] args){
54-
// Set the java truststore used by channelfinder
55-
configureTruststore();
56-
SpringApplication.run(Application.class, args);
57-
}
48+
public static void main(String[] args) {
49+
// Set the java truststore used by channelfinder
50+
configureTruststore();
51+
SpringApplication.run(Application.class, args);
52+
}
5853

59-
/**
60-
* Set the default ssl trust store
61-
*/
62-
private static void configureTruststore() {
63-
if (System.getProperty("javax.net.ssl.trustStore") == null) {
64-
logger.log(Level.INFO, "using default javax.net.ssl.trustStore");
65-
try (InputStream in = Application.class.getResourceAsStream("/keystore/cacerts")) {
66-
// read input
67-
File tempFile= File.createTempFile("cf-", "-truststore");
68-
FileOutputStream out = new FileOutputStream(tempFile);
69-
FileCopyUtils.copy(in, out);
70-
tempFile.deleteOnExit();
71-
System.setProperty("javax.net.ssl.trustStore", tempFile.getAbsolutePath());
72-
} catch (IOException e) {
73-
logger.log(Level.SEVERE, "failed to configure channelfinder truststore", e);
74-
}
75-
}
76-
if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
77-
logger.log(Level.INFO, "using default javax.net.ssl.trustStorePassword");
78-
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
79-
}
54+
/** Set the default ssl trust store */
55+
private static void configureTruststore() {
56+
if (System.getProperty("javax.net.ssl.trustStore") == null) {
57+
logger.log(Level.INFO, "using default javax.net.ssl.trustStore");
58+
try (InputStream in = Application.class.getResourceAsStream("/keystore/cacerts")) {
59+
// read input
60+
File tempFile = File.createTempFile("cf-", "-truststore");
61+
FileOutputStream out = new FileOutputStream(tempFile);
62+
FileCopyUtils.copy(in, out);
63+
tempFile.deleteOnExit();
64+
System.setProperty("javax.net.ssl.trustStore", tempFile.getAbsolutePath());
65+
} catch (IOException e) {
66+
logger.log(Level.SEVERE, "failed to configure channelfinder truststore", e);
67+
}
68+
}
69+
if (System.getProperty("javax.net.ssl.trustStorePassword") == null) {
70+
logger.log(Level.INFO, "using default javax.net.ssl.trustStorePassword");
71+
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
8072
}
73+
}
8174

82-
@Autowired
83-
PopulateService service;
75+
@Autowired PopulateService service;
8476

85-
public void run(ApplicationArguments args) throws Exception {
86-
if(args.containsOption("demo-data")) {
87-
int numberOfCells = args.getOptionValues("demo-data").stream().mapToInt(Integer::valueOf).max().orElse(1);
88-
logger.log(Level.INFO, "Populating the channelfinder service with demo data");
89-
service.createDB(numberOfCells);
90-
}
91-
if(args.containsOption("cleanup")) {
92-
int numberOfCells = args.getOptionValues("cleanup").stream().mapToInt(Integer::valueOf).max().orElse(1);
93-
// This is kind of a hack, the create Db is being called to reset the channels and then deleting them
94-
logger.log(Level.INFO, "Populating the channelfinder service with demo data first, then deleting them");
95-
service.createDB(numberOfCells);
96-
logger.log(Level.INFO, "Cleaning up the populated demo data");
97-
service.cleanupDB();
98-
}
77+
public void run(ApplicationArguments args) throws Exception {
78+
if (args.containsOption("demo-data")) {
79+
int numberOfCells =
80+
args.getOptionValues("demo-data").stream().mapToInt(Integer::valueOf).max().orElse(1);
81+
logger.log(Level.INFO, "Populating the channelfinder service with demo data");
82+
service.createDB(numberOfCells);
9983
}
100-
101-
/**
102-
* List of {@link ChannelProcessor} implementations called when new channels are created or existing channels are updated
103-
*
104-
* @return A list of {@link ChannelProcessor}s, if any have been registered over SPI.
105-
*/
106-
@Bean
107-
public List<ChannelProcessor> channelProcessors() {
108-
List<ChannelProcessor> processors = new ArrayList<>();
109-
ServiceLoader<ChannelProcessor> loader = ServiceLoader.load(ChannelProcessor.class);
110-
loader.stream().forEach(p -> {
111-
ChannelProcessor notifier = p.get();
112-
processors.add(notifier);
113-
});
114-
return processors;
84+
if (args.containsOption("cleanup")) {
85+
int numberOfCells =
86+
args.getOptionValues("cleanup").stream().mapToInt(Integer::valueOf).max().orElse(1);
87+
// This is kind of a hack, the create Db is being called to reset the channels and then
88+
// deleting them
89+
logger.log(
90+
Level.INFO,
91+
"Populating the channelfinder service with demo data first, then deleting them");
92+
service.createDB(numberOfCells);
93+
logger.log(Level.INFO, "Cleaning up the populated demo data");
94+
service.cleanupDB();
11595
}
96+
}
11697

117-
/**
118-
* {@link TaskExecutor} used when calling {@link ChannelProcessor}s.
119-
*
120-
* @return A {@link TaskExecutor}
121-
*/
122-
@Bean
123-
public TaskExecutor taskExecutor() {
124-
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
125-
taskExecutor.setCorePoolSize(3);
126-
taskExecutor.setMaxPoolSize(10);
127-
taskExecutor.setQueueCapacity(25);
98+
/**
99+
* List of {@link ChannelProcessor} implementations called when new channels are created or
100+
* existing channels are updated
101+
*
102+
* @return A list of {@link ChannelProcessor}s, if any have been registered over SPI.
103+
*/
104+
@Bean
105+
public List<ChannelProcessor> channelProcessors() {
106+
List<ChannelProcessor> processors = new ArrayList<>();
107+
ServiceLoader<ChannelProcessor> loader = ServiceLoader.load(ChannelProcessor.class);
108+
loader.stream()
109+
.forEach(
110+
p -> {
111+
ChannelProcessor notifier = p.get();
112+
processors.add(notifier);
113+
});
114+
return processors;
115+
}
128116

129-
return taskExecutor;
130-
}
117+
/**
118+
* {@link TaskExecutor} used when calling {@link ChannelProcessor}s.
119+
*
120+
* @return A {@link TaskExecutor}
121+
*/
122+
@Bean
123+
public TaskExecutor taskExecutor() {
124+
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
125+
taskExecutor.setCorePoolSize(3);
126+
taskExecutor.setMaxPoolSize(10);
127+
taskExecutor.setQueueCapacity(25);
131128

129+
return taskExecutor;
130+
}
132131
}

0 commit comments

Comments
 (0)