org.bidib.wizard.server.BiDiBWizardServerApplication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-server Show documentation
Show all versions of bidibwizard-server Show documentation
jBiDiB BiDiB Wizard Server POM
package org.bidib.wizard.server;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@SpringBootApplication(scanBasePackages = { "org.bidib.wizard.core.model", "org.bidib.wizard.core.service",
"org.bidib.wizard.core.config", "org.bidib.wizard.server.startup", "org.bidib.wizard.gateway.service",
"org.bidib.wizard.gateway.config", "org.bidib.wizard.server" })
@EnableAspectJAutoProxy
@EnableScheduling
@EnableWebMvc
// @EnableWebSecurity
public class BiDiBWizardServerApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(BiDiBWizardServerApplication.class);
public static void main(String[] args) {
List argsList = new ArrayList<>();
argsList.addAll(Arrays.asList(args));
final SpringApplicationBuilder builder =
new SpringApplicationBuilder().sources(BiDiBWizardServerApplication.class);
if (!"restartedMain".equals(Thread.currentThread().getName())) {
// add these extensions if the thread is not the devutils restarted main thread
// ConfigFileApplicationListener.CONFIG_NAME_PROPERTY
Optional wizardConfigFileName =
argsList.stream().filter(val -> val.startsWith("--wizard.settings.file-name")).findFirst();
if (wizardConfigFileName.isPresent()) {
LOGGER.info("Keep the provided data from args: {}", wizardConfigFileName.get());
String fileName = wizardConfigFileName.get().split("=")[1];
fileName = FilenameUtils.getBaseName(fileName);
LOGGER.info("Add the fileName: {}", fileName);
builder.properties("spring.config.name=application," + fileName);
}
else {
builder.properties("spring.config.name=application,wizard");
}
Optional wizardConfigFileLocation =
argsList.stream().filter(val -> val.startsWith("--wizard.settings.file-location")).findFirst();
if (wizardConfigFileLocation.isPresent()) {
LOGGER.info("Keep the provided data from args: {}", wizardConfigFileLocation.get());
String location = wizardConfigFileLocation.get().split("=")[1];
location = location.replaceAll("\\\\", "/");
if (!location.endsWith("/")) {
location += "/";
}
LOGGER.info("Set the optional additional-location: {}", location);
builder.properties("spring.config.additional-location=optional:file:///" + location);
}
else {
builder.properties("spring.config.additional-location=optional:file:///${user.home}/.bidib/");
}
}
builder.run(argsList.toArray(new String[0]));
}
}