Polishing in GroupsMetadata
See gh-33992
This commit is contained in:
@@ -142,10 +142,9 @@ public abstract class AbstractHttpServiceRegistrar implements
|
||||
|
||||
mergeGroups(proxyRegistryBeanDef);
|
||||
|
||||
this.groupsMetadata.forEachRegistration(group -> group.httpServiceTypeNames().forEach(type -> {
|
||||
this.groupsMetadata.forEachRegistration((groupName, types) -> types.forEach(type -> {
|
||||
GenericBeanDefinition proxyBeanDef = new GenericBeanDefinition();
|
||||
proxyBeanDef.setBeanClassName(type);
|
||||
String groupName = group.name();
|
||||
String beanName = (groupName + "#" + type);
|
||||
proxyBeanDef.setInstanceSupplier(() -> getProxyInstance(proxyRegistryBeanName, groupName, type));
|
||||
if (!beanRegistry.containsBeanDefinition(beanName)) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
@@ -54,16 +54,24 @@ final class GroupsMetadata {
|
||||
* Merge all registrations from the given {@link GroupsMetadata} into this one.
|
||||
*/
|
||||
public void mergeWith(GroupsMetadata other) {
|
||||
other.forEachRegistration(registration ->
|
||||
other.groupMap.values().forEach(registration ->
|
||||
getOrCreateGroup(registration.name(), registration.clientType())
|
||||
.httpServiceTypeNames()
|
||||
.addAll(registration.httpServiceTypeNames()));
|
||||
}
|
||||
|
||||
public void forEachRegistration(Consumer<Registration> consumer) {
|
||||
this.groupMap.values().forEach(consumer);
|
||||
/**
|
||||
* Callback to apply to all registrations with access to the group name and
|
||||
* its HTTP service type names.
|
||||
*/
|
||||
public void forEachRegistration(BiConsumer<String, Set<String>> consumer) {
|
||||
this.groupMap.values().forEach(registration ->
|
||||
consumer.accept(registration.name(), registration.httpServiceTypeNames()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the {@link HttpServiceGroup}s for all registrations.
|
||||
*/
|
||||
public Collection<HttpServiceGroup> groups() {
|
||||
return this.groupMap.values().stream().map(DefaultRegistration::toHttpServiceGroup).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user