diff --git a/roster/src/main/java/ch/unisg/roster/RosterApplication.java b/roster/src/main/java/ch/unisg/roster/RosterApplication.java index e21a679..973e8f1 100644 --- a/roster/src/main/java/ch/unisg/roster/RosterApplication.java +++ b/roster/src/main/java/ch/unisg/roster/RosterApplication.java @@ -4,14 +4,11 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.PostConstruct; - import ch.unisg.roster.roster.adapter.out.persistence.mongodb.RosterRepository; import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort; import ch.unisg.roster.roster.domain.Roster; import ch.unisg.roster.roster.domain.RosterItem; import org.eclipse.paho.client.mqttv3.MqttException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.ConfigurableEnvironment; @@ -29,14 +26,14 @@ public class RosterApplication { private static ConfigurableEnvironment ENVIRONMENT; - @Autowired - private LoadRosterItemPort loadRosterItemPort; + private static LoadRosterItemPort loadRosterItemPort; public static void main(String[] args) { SpringApplication rosterApp = new SpringApplication(RosterApplication.class); ENVIRONMENT = rosterApp.run(args).getEnvironment(); bootstrapMarketplaceWithMqtt(); + initialiseRoster(); } /** @@ -55,9 +52,9 @@ public class RosterApplication { } } - @PostConstruct - private void initialiseRoster(){ - Roster.getInstance().initialiseRoster(loadRosterItemPort.loadAllRosterItems()); + private static void initialiseRoster(){ + List rosterItemList = loadRosterItemPort.loadAllRosterItems(); + Roster.getInstance().initialiseRoster(rosterItemList); } }