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;
|
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() {
|
||||||
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
|
||||||
|
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