DatasetTool marker interface;
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package de.extio.lmdatasetprep;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -13,6 +14,8 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import de.extio.lmdatasetprep.preparer.DatasetTool;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCaching
|
||||
@ComponentScan(basePackages = { "de.extio.lmdatasetprep", "de.extio.lmlib" })
|
||||
@@ -31,12 +34,14 @@ public class LmDatasetPreparerApplication implements CommandLineRunner, Applicat
|
||||
public void run(final String... args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
LOGGER.error("Commandline argument is missing: Provide the tool name as argument");
|
||||
this.logAvailableTools();
|
||||
return;
|
||||
}
|
||||
|
||||
final var bean = applicationContext.getBean(args[0]);
|
||||
if (!(bean instanceof Consumer)) {
|
||||
if (!(bean instanceof Consumer) || !(bean instanceof DatasetTool)) {
|
||||
LOGGER.error("Invalid bean {}", args[0]);
|
||||
this.logAvailableTools();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,6 +54,10 @@ public class LmDatasetPreparerApplication implements CommandLineRunner, Applicat
|
||||
}
|
||||
}
|
||||
|
||||
private void logAvailableTools() {
|
||||
LOGGER.error("Available tools: {}", Arrays.toString(applicationContext.getBeanNamesForType(DatasetTool.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(final ApplicationContext appContext) throws BeansException {
|
||||
applicationContext = appContext;
|
||||
|
||||
Reference in New Issue
Block a user