mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 19:55:48 +01:00
* Fixes #3946 Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
369bd228e7
commit
924e7b2d6d
@ -173,31 +173,39 @@ public class AddonSuggestionService implements AutoCloseable {
|
|||||||
|
|
||||||
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
|
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
|
||||||
public void addAddonFinder(AddonFinder addonFinder) {
|
public void addAddonFinder(AddonFinder addonFinder) {
|
||||||
addonFinders.add(addonFinder);
|
synchronized (addonFinders) {
|
||||||
|
addonFinders.add(addonFinder);
|
||||||
|
}
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAddonFinder(AddonFinder addonFinder) {
|
public void removeAddonFinder(AddonFinder addonFinder) {
|
||||||
if (addonFinders.remove(addonFinder)) {
|
synchronized (addonFinders) {
|
||||||
changed();
|
addonFinders.remove(addonFinder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changed() {
|
private void changed() {
|
||||||
List<AddonInfo> candidates = addonInfoProviders.stream().map(p -> p.getAddonInfos(localeProvider.getLocale()))
|
List<AddonInfo> candidates = addonInfoProviders.stream().map(p -> p.getAddonInfos(localeProvider.getLocale()))
|
||||||
.flatMap(Collection::stream).toList();
|
.flatMap(Collection::stream).toList();
|
||||||
addonFinders.stream().filter(this::isFinderEnabled).forEach(f -> f.setAddonCandidates(candidates));
|
synchronized (addonFinders) {
|
||||||
|
addonFinders.stream().filter(this::isFinderEnabled).forEach(f -> f.setAddonCandidates(candidates));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deactivate
|
@Deactivate
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
addonFinders.clear();
|
synchronized (addonFinders) {
|
||||||
|
addonFinders.clear();
|
||||||
|
}
|
||||||
addonInfoProviders.clear();
|
addonInfoProviders.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<AddonInfo> getSuggestedAddons(@Nullable Locale locale) {
|
public Set<AddonInfo> getSuggestedAddons(@Nullable Locale locale) {
|
||||||
return addonFinders.stream().filter(this::isFinderEnabled).map(f -> f.getSuggestedAddons())
|
synchronized (addonFinders) {
|
||||||
.flatMap(Collection::stream).collect(Collectors.toSet());
|
return addonFinders.stream().filter(this::isFinderEnabled).map(f -> f.getSuggestedAddons())
|
||||||
|
.flatMap(Collection::stream).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user