ChannelsEndpoint should return a Map<> (not a domain object)
This is a general rule for endpoints so they work OOTB with JMX.
This commit is contained in:
@@ -137,12 +137,12 @@ public class ChannelBindingService implements InitializingBean {
|
||||
catch (Exception e) {
|
||||
throw new IllegalStateException("Could not get the message channel to configure message converters" + e);
|
||||
}
|
||||
BindingProperties bindingProperties = channelBindingServiceProperties.getBindings().get(channelName);
|
||||
BindingProperties bindingProperties = this.channelBindingServiceProperties.getBindings().get(channelName);
|
||||
if (bindingProperties != null) {
|
||||
String contentType = bindingProperties.getContentType();
|
||||
if (StringUtils.hasText(contentType)) {
|
||||
MimeType mimeType = MessageConverterUtils.getMimeType(contentType);
|
||||
MessageConverter messageConverter = messageConverterFactory.newInstance(mimeType);
|
||||
MessageConverter messageConverter = this.messageConverterFactory.newInstance(mimeType);
|
||||
Class<?> dataType = MessageConverterUtils.getJavaTypeForContentType(mimeType,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
messageChannel.setDatatypes(dataType);
|
||||
|
||||
@@ -24,17 +24,16 @@ import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||
import org.springframework.cloud.stream.binding.Bindable;
|
||||
import org.springframework.cloud.stream.config.BindingProperties;
|
||||
import org.springframework.cloud.stream.config.ChannelBindingServiceProperties;
|
||||
import org.springframework.cloud.stream.endpoint.ChannelsEndpoint.ChannelsMetaData;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RestController
|
||||
public class ChannelsEndpoint extends AbstractEndpoint<ChannelsMetaData> {
|
||||
public class ChannelsEndpoint extends AbstractEndpoint<Map<String,Object>> {
|
||||
|
||||
private List<Bindable> adapters;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class ChannelsEndpoint extends AbstractEndpoint<ChannelsMetaData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelsMetaData invoke() {
|
||||
public Map<String,Object> invoke() {
|
||||
ChannelsMetaData map = new ChannelsMetaData();
|
||||
Map<String, BindingProperties> inputs = map.getInputs();
|
||||
Map<String, BindingProperties> outputs = map.getOutputs();
|
||||
@@ -63,7 +62,8 @@ public class ChannelsEndpoint extends AbstractEndpoint<ChannelsMetaData> {
|
||||
: new BindingProperties());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
return new ObjectMapper().convertValue(map, new TypeReference<Map<String,Object>>() {
|
||||
});
|
||||
}
|
||||
|
||||
@JsonInclude(value = Include.NON_DEFAULT)
|
||||
|
||||
Reference in New Issue
Block a user