add property spring.guice.modules.exclude to filter guice modules by name
This commit is contained in:
committed by
Taylor Wicksell
parent
b505c0867d
commit
697d2ede55
@@ -15,6 +15,7 @@ package org.springframework.guice.annotation;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -172,6 +173,14 @@ class ModuleRegistryConfiguration
|
||||
elements = removeDuplicates(elements);
|
||||
modules = Collections.singletonList(Elements.getModule(elements));
|
||||
}
|
||||
if (applicationContext.getEnvironment().containsProperty("spring.guice.modules.exclude")) {
|
||||
String[] modulesToFilter = applicationContext.getEnvironment()
|
||||
.getProperty("spring.guice.modules.exclude").split(",");
|
||||
elements = elements.stream()
|
||||
.filter(e -> !Arrays.stream(modulesToFilter)
|
||||
.filter(ex -> (e.getSource().toString().contains(ex))).findFirst().isPresent())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
for (Element e : elements) {
|
||||
if (e instanceof Binding) {
|
||||
Binding<?> binding = (Binding<?>) e;
|
||||
|
||||
Reference in New Issue
Block a user