GH-1476, GH-1568 exposed actual binding name

Exposed the actual binding name in addition to already exposed destination name of the binding
Fixed Actuator endpoint to ensure it uses binding name

Resolves #1476
Resolves #1568
This commit is contained in:
Oleg Zhurakousky
2019-01-22 08:51:12 +01:00
parent 2fa4e1cc75
commit 144627c435
3 changed files with 25 additions and 7 deletions

View File

@@ -92,14 +92,25 @@ public interface Binding<T> extends Pausable {
}
/**
* Returns the name of this binding (i.e., channel name)
* Returns the name of the destination for this binding
*
* @return binding name
* @return destination name
*/
default String getName() {
return null;
}
/**
* Returns the name of the target for this binding (i.e., channel name)
*
* @return binding name
*
* @since 2.2
*/
default String getBindingName() {
return null;
}
/**
* Unbinds the target component represented by this instance and stops any active
* components. Implementations must be idempotent. After this method is invoked, the

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2018 the original author or authors.
* Copyright 2013-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.Lifecycle;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.endpoint.Pausable;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.util.Assert;
@@ -39,7 +40,7 @@ import org.springframework.util.StringUtils;
*
* @see org.springframework.cloud.stream.annotation.EnableBinding
*/
@JsonPropertyOrder({ "name", "group", "pausable", "state"})
@JsonPropertyOrder({ "name", "bindingName", "group", "pausable", "state"})
@JsonIgnoreProperties("running")
public class DefaultBinding<T> implements Binding<T> {
@@ -84,6 +85,12 @@ public class DefaultBinding<T> implements Binding<T> {
return this.name;
}
public String getBindingName() {
String resolvedName = (this.target instanceof IntegrationObjectSupport)
? ((IntegrationObjectSupport)this.target).getComponentName() : getName();
return resolvedName == null ? getName() : resolvedName;
}
public String getGroup() {
return this.group;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018 the original author or authors.
* Copyright 2018-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,10 +116,10 @@ public class BindingsEndpoint {
return outputBindings;
}
private Binding<?> locateBinding(String name) {
private Binding<?> locateBinding(String bindingName) {
Stream<Binding<?>> bindings = Stream.concat(this.gatherInputBindings().stream(), this.gatherOutputBindings().stream());
return bindings
.filter(binding -> name.equals(binding.getName()))
.filter(binding -> bindingName.equals(binding.getBindingName()))
.findFirst()
.orElse(null);
}