package de.nbscloud.webcontainer.registry; import org.springframework.stereotype.Component; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @Component public class AppRegistry { private final List apps = new CopyOnWriteArrayList<>(); public void registerApp(App app) { this.apps.add(app); this.apps.sort(Comparator.comparing(App::getIndex)); } public List getAll() { return Collections.unmodifiableList(this.apps); } }