INT-2738 Add Missing getComponentType() Methods
JIRA: https://jira.spring.io/browse/INT-2738 Add a `getComponentType()` method for all handlers, message producers, and message sources that implement `NamedComponent` (see `SPCA.getComponentType()`). Add rome as an optional dependency - STS complained because AtomFeedHttpMessageConverter has a dependency on it.
This commit is contained in:
committed by
Artem Bilan
parent
3839eca5ca
commit
a7489909d7
@@ -67,6 +67,11 @@ public class JsonToObjectTransformer extends AbstractTransformer implements Bean
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "json-to-object-transformer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doTransform(Message<?> message) throws Exception {
|
||||
if (this.targetClass != null) {
|
||||
|
||||
@@ -86,6 +86,11 @@ public class ObjectToJsonTransformer extends AbstractTransformer {
|
||||
this.contentType = contentType.trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "object-to-json-transformer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doTransform(Message<?> message) throws Exception {
|
||||
Object payload = ResultType.STRING.equals(this.resultType)
|
||||
|
||||
@@ -43,6 +43,10 @@ public class ClaimCheckInTransformer extends AbstractTransformer {
|
||||
this.messageStore = messageStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "claim-check-in";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doTransform(Message<?> message) throws Exception {
|
||||
|
||||
@@ -54,6 +54,11 @@ public class ClaimCheckOutTransformer extends AbstractTransformer {
|
||||
this.removeMessage = removeMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "claim-check-out";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doTransform(Message<?> message) throws Exception {
|
||||
Assert.notNull(message, "message must not be null");
|
||||
|
||||
@@ -214,10 +214,15 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
|
||||
this.sourceEvaluationContext = evaluationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Content Enricher. Will instantiate an internal Gateway if
|
||||
* the requestChannel is set.
|
||||
*/
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "enricher";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Content Enricher. Will instantiate an internal Gateway if
|
||||
* the requestChannel is set.
|
||||
*/
|
||||
@Override
|
||||
protected void doInit() {
|
||||
if (StringUtils.hasText(this.requestChannelName)) {
|
||||
@@ -383,6 +388,12 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
|
||||
protected Message<?> sendAndReceiveMessage(Object object) {
|
||||
return super.sendAndReceiveMessage(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "enricher$gateway";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ public class HeaderFilter extends IntegrationObjectSupport implements Transforme
|
||||
this.patternMatch = patternMatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "header-filter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<?> transform(Message<?> message) {
|
||||
AbstractIntegrationMessageBuilder<?> builder = this.getMessageBuilderFactory().fromMessage(message);
|
||||
|
||||
@@ -62,6 +62,19 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?, ?>
|
||||
this.targetClass = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "map-to-object-transformer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
if (StringUtils.hasText(this.targetBeanName)) {
|
||||
Assert.isTrue(this.getBeanFactory().isPrototype(this.targetBeanName),
|
||||
"target bean [" + targetBeanName + "] must have 'prototype' scope");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object transformPayload(Map<?, ?> payload) throws Exception {
|
||||
Object target = (this.targetClass != null)
|
||||
@@ -79,12 +92,4 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?, ?>
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
if (StringUtils.hasText(this.targetBeanName)) {
|
||||
Assert.isTrue(this.getBeanFactory().isPrototype(this.targetBeanName),
|
||||
"target bean [" + targetBeanName + "] must have 'prototype' scope");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
|
||||
this.shouldFlattenKeys = shouldFlattenKeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Map<String, Object> transformPayload(Object payload) throws Exception {
|
||||
Map<String,Object> result = this.jsonObjectMapper.fromJson(this.jsonObjectMapper.toJson(payload), Map.class);
|
||||
@@ -71,6 +72,28 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "object-to-map-transformer";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void doProcessElement(String propertyPrefix, Object element, Map<String, Object> resultMap) {
|
||||
if (element instanceof Map) {
|
||||
this.doFlatten(propertyPrefix, (Map<String, Object>) element, resultMap);
|
||||
}
|
||||
else if (element instanceof Collection) {
|
||||
this.doProcessCollection(propertyPrefix, (Collection<?>) element, resultMap);
|
||||
}
|
||||
else if (element != null && element.getClass().isArray()) {
|
||||
Collection<?> collection = CollectionUtils.arrayToList(element);
|
||||
this.doProcessCollection(propertyPrefix, collection, resultMap);
|
||||
}
|
||||
else {
|
||||
resultMap.put(propertyPrefix, element);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> flattenMap(Map<String,Object> result){
|
||||
Map<String,Object> resultMap = new HashMap<String, Object>();
|
||||
this.doFlatten("", result, resultMap);
|
||||
@@ -95,21 +118,4 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void doProcessElement(String propertyPrefix, Object element, Map<String, Object> resultMap) {
|
||||
if (element instanceof Map) {
|
||||
this.doFlatten(propertyPrefix, (Map<String, Object>) element, resultMap);
|
||||
}
|
||||
else if (element instanceof Collection) {
|
||||
this.doProcessCollection(propertyPrefix, (Collection<?>) element, resultMap);
|
||||
}
|
||||
else if (element != null && element.getClass().isArray()) {
|
||||
Collection<?> collection = CollectionUtils.arrayToList(element);
|
||||
this.doProcessCollection(propertyPrefix, collection, resultMap);
|
||||
}
|
||||
else {
|
||||
resultMap.put(propertyPrefix, element);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -46,6 +46,11 @@ public class ObjectToStringTransformer extends AbstractPayloadTransformer<Object
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "object-to-string-transformer";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String transformPayload(Object payload) throws Exception {
|
||||
if (payload instanceof byte[]) {
|
||||
|
||||
Reference in New Issue
Block a user