feature/config #78
@ -11,18 +11,18 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component("appSettings")
|
||||||
public class AppSettings {
|
public class AppSettings {
|
||||||
|
|
||||||
private static YAMLData data;
|
private YAMLData data;
|
||||||
|
|
||||||
private static String installationName;
|
private String installationName;
|
||||||
private static String companyName;
|
private String companyName;
|
||||||
private static Address companyAddress;
|
private Address companyAddress;
|
||||||
private static int numberOfStorageSpaces;
|
private int numberOfStorageSpaces;
|
||||||
private static List<YAMLData.Supplier> suppliers;
|
private List<YAMLData.Supplier> suppliers;
|
||||||
private static String parcelServiceName;
|
private String parcelServiceName;
|
||||||
private static String parcelServiceApiURL;
|
private String parcelServiceApiURL;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
/**
|
/**
|
||||||
@ -119,35 +119,35 @@ public class AppSettings {
|
|||||||
return data;
|
return data;
|
||||||
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static YAMLData getData() {
|
public YAMLData getData() {
|
||||||
return data;
|
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;
|
return installationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCompanyName() {
|
public String getCompanyName() {
|
||||||
return companyName;
|
return companyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Address getCompanyAddress() {
|
public Address getCompanyAddress() {
|
||||||
return companyAddress;
|
return companyAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getNumberOfStorageSpaces() {
|
public int getNumberOfStorageSpaces() {
|
||||||
return numberOfStorageSpaces;
|
return numberOfStorageSpaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<YAMLData.Supplier> getSuppliers() {
|
public List<YAMLData.Supplier> getSuppliers() {
|
||||||
return suppliers;
|
return suppliers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getParcelServiceName() {
|
public String getParcelServiceName() {
|
||||||
return parcelServiceName;
|
return parcelServiceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getParcelServiceApiURL() {
|
public String getParcelServiceApiURL() {
|
||||||
return parcelServiceApiURL;
|
return parcelServiceApiURL;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,10 +14,13 @@ public class SlotInitializer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private final SlotRepository slotRepository = null;
|
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
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
|
int NUM_SLOTS = appSettings.getNumberOfStorageSpaces();
|
||||||
|
|
||||||
for (int i = 1; i <= NUM_SLOTS; i++) {
|
for (int i = 1; i <= NUM_SLOTS; i++) {
|
||||||
if (!slotRepository.findBySlotNum(i).isPresent()) {
|
if (!slotRepository.findBySlotNum(i).isPresent()) {
|
||||||
Slot slotAdded = new Slot();
|
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.