feature/config #78
@ -11,18 +11,18 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Component
|
||||
@Component("appSettings")
|
||||
public class AppSettings {
|
||||
|
||||
private static YAMLData data;
|
||||
private YAMLData data;
|
||||
|
||||
private static String installationName;
|
||||
private static String companyName;
|
||||
private static Address companyAddress;
|
||||
private static int numberOfStorageSpaces;
|
||||
private static List<YAMLData.Supplier> suppliers;
|
||||
private static String parcelServiceName;
|
||||
private static String parcelServiceApiURL;
|
||||
private String installationName;
|
||||
private String companyName;
|
||||
private Address companyAddress;
|
||||
private int numberOfStorageSpaces;
|
||||
private List<YAMLData.Supplier> suppliers;
|
||||
private String parcelServiceName;
|
||||
private String parcelServiceApiURL;
|
||||
|
||||
@PostConstruct
|
||||
/**
|
||||
@ -119,35 +119,35 @@ public class AppSettings {
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
public static YAMLData getData() {
|
||||
public YAMLData getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public static String getInstallationName() {
|
||||
public String getInstallationName() {
|
||||
CodeSteak
commented
In den Getter ist nicht sichergestellt, dass die werte schon initialisiert sind. Andere Komponenten könnten schon vorher PostConstruct ausgeführt haben. In den Getter ist nicht sichergestellt, dass die werte schon initialisiert sind. Andere Komponenten könnten schon vorher PostConstruct ausgeführt haben.
|
||||
return installationName;
|
||||
}
|
||||
|
||||
public static String getCompanyName() {
|
||||
public String getCompanyName() {
|
||||
return companyName;
|
||||
}
|
||||
|
||||
public static Address getCompanyAddress() {
|
||||
public Address getCompanyAddress() {
|
||||
return companyAddress;
|
||||
}
|
||||
|
||||
public static int getNumberOfStorageSpaces() {
|
||||
public int getNumberOfStorageSpaces() {
|
||||
return numberOfStorageSpaces;
|
||||
}
|
||||
|
||||
public static List<YAMLData.Supplier> getSuppliers() {
|
||||
public List<YAMLData.Supplier> getSuppliers() {
|
||||
return suppliers;
|
||||
}
|
||||
|
||||
public static String getParcelServiceName() {
|
||||
public String getParcelServiceName() {
|
||||
return parcelServiceName;
|
||||
}
|
||||
|
||||
public static String getParcelServiceApiURL() {
|
||||
public String getParcelServiceApiURL() {
|
||||
return parcelServiceApiURL;
|
||||
}
|
||||
}
|
@ -14,10 +14,13 @@ public class SlotInitializer {
|
||||
@Autowired
|
||||
private final SlotRepository slotRepository = null;
|
||||
|
||||
private final int NUM_SLOTS = AppSettings.getNumberOfStorageSpaces();
|
||||
@Autowired
|
||||
CodeSteak
commented
Muss in init() eingelesen werden wegen obigen Problem Muss in init() eingelesen werden wegen obigen Problem
|
||||
private final AppSettings appSettings = null;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
int NUM_SLOTS = appSettings.getNumberOfStorageSpaces();
|
||||
|
||||
for (int i = 1; i <= NUM_SLOTS; i++) {
|
||||
if (!slotRepository.findBySlotNum(i).isPresent()) {
|
||||
Slot slotAdded = new Slot();
|
||||
|
Reference in New Issue
Block a user
Führt nach im catch(...) Fall evtl zu null pointer deref. Vlcht im catch leere werte setzen oder app beenden.
Wollen wir mit leeren Werten starten oder beenden? Ich hab jetzt mal ein
System.exit()
eingebaut.