use @Autowired to get AppSettings Object
This commit is contained in:
parent
774e62f892
commit
d5825ba7a0
|
@ -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() {
|
||||
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
|
||||
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