INT-3094 Fix JSON and Core Package Tangles

INT-3094 Fix JSON Package Tangle

Move JSON 'discovery' classes to .support.json (used by
.json and .transformer - ObjectToMapTransformer)

INT-3094 Fix JSON Class Tangle

Separate factory methods to avoid class tangle.

Remove tight tangle between parser and mapper.

INT-3094 Fix Core Package Tangle

Move NamedComponent from .context to .support.context

(Used by .history, and .context references .store which references
.history through .util.)

INT-3094: fix 'support.json' package class-cycle

INT-3094 Polishing - PR Comments

Remove parser provider and make parsers public.
This commit is contained in:
Gary Russell
2013-07-18 14:42:47 -04:00
parent d6776b4889
commit d0e17b3995
49 changed files with 343 additions and 166 deletions

View File

@@ -36,6 +36,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.Connection;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
@@ -56,13 +57,13 @@ import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -16,6 +16,7 @@ package org.springframework.integration.config;
import java.util.List;
import org.aopalliance.aop.Advice;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -24,7 +25,6 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.context.Orderable;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageProducer;

View File

@@ -18,8 +18,6 @@ package org.springframework.integration.config.xml;
import org.w3c.dom.Element;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.util.StringUtils;

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -27,6 +28,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -18,9 +18,9 @@ package org.springframework.integration.endpoint;
import org.springframework.context.Lifecycle;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -19,11 +19,11 @@ package org.springframework.integration.endpoint;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.history.TrackableComponent;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.transaction.IntegrationResourceHolder;
import org.springframework.util.Assert;

View File

@@ -16,15 +16,16 @@
package org.springframework.integration.handler;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.filter.MessageFilter;
@@ -32,10 +33,6 @@ import org.springframework.integration.support.channel.BeanFactoryChannelResolve
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.util.Assert;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* A composite {@link MessageHandler} implementation that invokes a chain of
* MessageHandler instances in order.

View File

@@ -26,8 +26,8 @@ import java.util.ListIterator;
import java.util.Properties;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.history;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;

View File

@@ -16,6 +16,9 @@
package org.springframework.integration.json;
import org.springframework.integration.support.json.JacksonJsonObjectMapper;
import org.springframework.integration.support.json.JacksonJsonObjectMapperProvider;
import org.springframework.integration.support.json.JsonObjectMapper;
import org.springframework.integration.transformer.AbstractPayloadTransformer;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

View File

@@ -18,6 +18,9 @@ package org.springframework.integration.json;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.JacksonJsonObjectMapper;
import org.springframework.integration.support.json.JacksonJsonObjectMapperProvider;
import org.springframework.integration.support.json.JsonObjectMapper;
import org.springframework.integration.transformer.AbstractTransformer;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.context;
package org.springframework.integration.support.context;
/**
* @author Mark Fisher

View File

@@ -0,0 +1,4 @@
/**
* Provides classes supporting use of the application context.
*/
package org.springframework.integration.support.context;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import org.springframework.integration.Message;
import org.springframework.integration.support.MessageBuilder;
@@ -30,9 +30,9 @@ import org.springframework.integration.support.MessageBuilder;
*/
abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessageMapper.JsonMessageParser<P> {
protected final JsonObjectMapper<P> objectMapper;
private final JsonObjectMapper<P> objectMapper;
protected volatile JsonInboundMessageMapper messageMapper;
private volatile JsonInboundMessageMapper messageMapper;
protected AbstractJacksonJsonMessageParser(JsonObjectMapper<P> objectMapper) {
this.objectMapper = objectMapper;
@@ -44,22 +44,36 @@ abstract class AbstractJacksonJsonMessageParser<P> implements JsonInboundMessage
this.messageMapper = messageMapper;
}
P parser = this.createJsonParser(jsonMessage);
if (messageMapper.isMapToPayload()) {
try {
return MessageBuilder.withPayload(this.readPayload(parser)).build();
}
catch (Exception ex) {
throw new IllegalArgumentException("Mapping of JSON message " + jsonMessage +
" directly to payload of type " + messageMapper.getPayloadType() + " failed.", ex);
}
Object payload = this.readPayload(parser, jsonMessage);
return MessageBuilder.withPayload(payload).build();
}
else {
return this.parseWithHeaders(parser, jsonMessage);
}
}
protected Object readPayload(P parser) throws Exception {
return objectMapper.fromJson(parser, this.messageMapper.getPayloadType());
protected Object readPayload(P parser, String jsonMessage) throws Exception {
try {
return objectMapper.fromJson(parser, this.messageMapper.getPayloadType());
}
catch (Exception e) {
throw new IllegalArgumentException("Mapping of JSON message '" + jsonMessage +
"' to payload type '" + messageMapper.getPayloadType() + "' failed.", e);
}
}
protected Object readHeader(P parser, String headerName, String jsonMessage) throws Exception {
Class<?> headerType = this.messageMapper.getHeaderTypes().containsKey(headerName) ?
this.messageMapper.getHeaderTypes().get(headerName) : Object.class;
try {
return this.objectMapper.fromJson(parser, headerType);
}
catch (Exception e) {
throw new IllegalArgumentException("Mapping header '" + headerName + "' of JSON message '" +
jsonMessage + "' to header type '" + headerType + "' failed.", e);
}
}
protected abstract Message<?> parseWithHeaders(P parser, String jsonMessage) throws Exception;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.lang.reflect.Type;
import java.util.HashMap;

View File

@@ -14,21 +14,20 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.util.LinkedHashMap;
import java.util.Map;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.JsonMappingException;
import org.springframework.integration.Message;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.util.Assert;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
/**
* {@link JsonInboundMessageMapper.JsonMessageParser} implementation that parses JSON messages
* and builds a {@link Message} with the specified payload type from provided {@link JsonInboundMessageMapper}.
@@ -37,7 +36,7 @@ import org.springframework.util.Assert;
* @author Artem Bilan
* @since 3.0
*/
class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<JsonParser> {
public class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<JsonParser> {
public Jackson2JsonMessageParser() {
super(new Jackson2JsonObjectMapper());
@@ -51,11 +50,11 @@ class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<JsonPar
@Override
protected Message<?> parseWithHeaders(JsonParser parser, String jsonMessage) throws Exception {
String error = AbstractJsonInboundMessageMapper.MESSAGE_FORMAT_ERROR + jsonMessage;
Assert.isTrue(parser.nextToken() == JsonToken.START_OBJECT, error);
Assert.isTrue(JsonToken.START_OBJECT == parser.nextToken(), error);
Map<String, Object> headers = null;
Object payload = null;
while (parser.nextToken() != JsonToken.END_OBJECT) {
Assert.isTrue(parser.getCurrentToken() == JsonToken.FIELD_NAME, error);
while (JsonToken.END_OBJECT != parser.nextToken()) {
Assert.isTrue(JsonToken.FIELD_NAME == parser.getCurrentToken(), error);
boolean isHeadersToken = "headers".equals(parser.getCurrentName());
boolean isPayloadToken = "payload".equals(parser.getCurrentName());
Assert.isTrue(isHeadersToken || isPayloadToken, error);
@@ -65,13 +64,7 @@ class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<JsonPar
}
else if (isPayloadToken) {
parser.nextToken();
try {
payload = this.readPayload(parser);
}
catch (JsonMappingException ex) {
throw new IllegalArgumentException("Mapping payload of JSON message " + jsonMessage +
" to payload type " + messageMapper.getPayloadType() + " failed.", ex);
}
payload = this.readPayload(parser, jsonMessage);
}
}
Assert.notNull(headers, error);
@@ -80,18 +73,11 @@ class Jackson2JsonMessageParser extends AbstractJacksonJsonMessageParser<JsonPar
private Map<String, Object> readHeaders(JsonParser parser, String jsonMessage) throws Exception {
Map<String, Object> headers = new LinkedHashMap<String, Object>();
while (parser.nextToken() != JsonToken.END_OBJECT) {
while (JsonToken.END_OBJECT != parser.nextToken()) {
String headerName = parser.getCurrentName();
parser.nextToken();
Class<?> headerType = this.messageMapper.getHeaderTypes().containsKey(headerName) ?
this.messageMapper.getHeaderTypes().get(headerName) : Object.class;
try {
headers.put(headerName, this.objectMapper.fromJson(parser, headerType));
}
catch (JsonMappingException ex) {
throw new IllegalArgumentException("Mapping header \"" + headerName + "\" of JSON message " +
jsonMessage + " to header type " + messageMapper.getPayloadType() + " failed.", ex);
}
Object headerValue = this.readHeader(parser, headerName, jsonMessage);
headers.put(headerName, headerValue);
}
return headers;
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.io.Reader;
import java.io.Writer;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -22,7 +22,7 @@ import java.util.Map;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.JsonMappingException;
import org.springframework.integration.Message;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.util.Assert;
@@ -35,9 +35,9 @@ import org.springframework.util.Assert;
* @author Artem Bilan
* @since 3.0
*/
class JacksonJsonMessageParser extends AbstractJacksonJsonMessageParser<JsonParser> {
public class JacksonJsonMessageParser extends AbstractJacksonJsonMessageParser<JsonParser> {
JacksonJsonMessageParser() {
public JacksonJsonMessageParser() {
super(new JacksonJsonObjectMapper());
}
@@ -63,13 +63,7 @@ class JacksonJsonMessageParser extends AbstractJacksonJsonMessageParser<JsonPars
}
else if (isPayloadToken) {
parser.nextToken();
try {
payload = this.readPayload(parser);
}
catch (JsonMappingException ex) {
throw new IllegalArgumentException("Mapping payload of JSON message " + jsonMessage +
" to payload type " + messageMapper.getPayloadType() + " failed.", ex);
}
payload = this.readPayload(parser, jsonMessage);
}
}
Assert.notNull(headers, error);
@@ -81,15 +75,8 @@ class JacksonJsonMessageParser extends AbstractJacksonJsonMessageParser<JsonPars
while (parser.nextToken() != JsonToken.END_OBJECT) {
String headerName = parser.getCurrentName();
parser.nextToken();
Class<?> headerType = this.messageMapper.getHeaderTypes().containsKey(headerName) ?
this.messageMapper.getHeaderTypes().get(headerName) : Object.class;
try {
headers.put(headerName, this.objectMapper.fromJson(parser, headerType));
}
catch (JsonMappingException ex) {
throw new IllegalArgumentException("Mapping header \"" + headerName + "\" of JSON message " +
jsonMessage + " to header type " + messageMapper.getPayloadType() + " failed.", ex);
}
Object headerValue = this.readHeader(parser, headerName, jsonMessage);
headers.put(headerName, headerValue);
}
return headers;
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.io.Reader;
import java.io.Writer;

View File

@@ -0,0 +1,45 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.support.json;
/**
* Simple factory to provide {@linkplain Jackson2JsonObjectMapper} or {@linkplain JacksonJsonObjectMapper}
* instances dependently of jackson-databind or jackson-mapper-asl libs in the classpath.
* If there are both libs in the classpath, it prefers Jackson 2 JSON-processor implementation.
* If there is not any of them, {@linkplain IllegalStateException} will be thrown.
*
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*
* @see Jackson2JsonObjectMapper
* @see JacksonJsonObjectMapper
*/
public final class JacksonJsonObjectMapperProvider {
public static JsonObjectMapper<?> newInstance() {
if (JacksonJsonUtils.isJackson2Present()) {
return new Jackson2JsonObjectMapper();
}
if(JacksonJsonUtils.isJacksonPresent()) {
return new JacksonJsonObjectMapper();
}
throw JacksonJsonUtils.getNoJacksonLibException();
}
}

View File

@@ -14,27 +14,21 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import org.springframework.util.ClassUtils;
/**
* Simple factory to provide {@linkplain Jackson2JsonObjectMapper} or {@linkplain JacksonJsonObjectMapper}
* instances dependently of jackson-databind or jackson-mapper-asl libs in the classpath.
* If there are both libs in the classpath, it prefers Jackson 2 JSON-processor implementation.
* If there is no any of them, {@linkplain IllegalStateException} will be thrown.
* Utility methods for Jackson.
*
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*
* @see Jackson2JsonObjectMapper
* @see JacksonJsonObjectMapper
* @see JsonToObjectTransformer
* @see ObjectToJsonTransformer
*/
public final class JacksonJsonObjectMapperProvider {
public final class JacksonJsonUtils {
private static final ClassLoader classLoader = JacksonJsonObjectMapperProvider.class.getClassLoader();
private static final ClassLoader classLoader = JacksonJsonUtils.class.getClassLoader();
private static final boolean jackson2Present =
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", classLoader) &&
@@ -47,24 +41,15 @@ public final class JacksonJsonObjectMapperProvider {
private static final IllegalStateException NO_JACKSON_LIB_EXCEPTION =
new IllegalStateException("Neither jackson-databind.jar, nor jackson-mapper-asl.jar aren't presented in the classpath.");
public static JsonObjectMapper<?> newInstance() {
if (jackson2Present) {
return new Jackson2JsonObjectMapper();
}
if(jacksonPresent) {
return new JacksonJsonObjectMapper();
}
throw NO_JACKSON_LIB_EXCEPTION;
public static boolean isJackson2Present() {
return jackson2Present;
}
public static JsonInboundMessageMapper.JsonMessageParser<?> newJsonMessageParser() {
if (jackson2Present) {
return new Jackson2JsonMessageParser();
}
if(jacksonPresent) {
return new Jackson2JsonMessageParser();
}
throw NO_JACKSON_LIB_EXCEPTION;
public static boolean isJacksonPresent() {
return jacksonPresent;
}
public static IllegalStateException getNoJacksonLibException() {
return NO_JACKSON_LIB_EXCEPTION;
}
}

View File

@@ -14,45 +14,38 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.lang.reflect.Type;
import java.util.Map;
import org.springframework.integration.Message;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
import org.springframework.util.Assert;
/**
* {@link org.springframework.integration.mapping.InboundMessageMapper} implementation that maps incoming JSON messages
* to a {@link Message} with the specified payload type.
* By default it uses {@link JacksonJsonObjectMapperProvider} to get Jackson or Jackson 2 {@link JsonMessageParser}
* implementation dependently from classpath.
* Any other {@link JsonMessageParser} implementation may be provided through the appropriate constructor.
*
* @author Jeremy Grelle
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
* @since 2.0
*/
public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<JsonInboundMessageMapper.JsonMessageParser<?>> {
public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<JsonMessageParser<?>> {
private volatile JsonMessageParser<?> messageParser;
public JsonInboundMessageMapper(Class<?> payloadType) {
this((Type) payloadType);
}
public JsonInboundMessageMapper(Type payloadType) {
this(payloadType, null);
}
public JsonInboundMessageMapper(Class<?> payloadType, JsonMessageParser<?> messageParser) {
this((Type) payloadType, messageParser);
}
public JsonInboundMessageMapper(Type payloadType, JsonMessageParser<?> messageParser) {
super(payloadType);
this.messageParser = messageParser != null ? messageParser : JacksonJsonObjectMapperProvider.newJsonMessageParser();
Assert.notNull(messageParser, "'messageParser' cannot be null");
this.messageParser = messageParser;
}
public boolean isMapToPayload() {
@@ -83,7 +76,6 @@ public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<J
return null;
}
public static interface JsonMessageParser<P> {
Message<?> doInParser(JsonInboundMessageMapper messageMapper, String jsonMessage) throws Exception;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.io.Reader;
import java.io.Writer;
@@ -26,10 +26,6 @@ import java.lang.reflect.Type;
* @author Artem Bilan
* @since 3.0
*
* @see JsonToObjectTransformer
* @see ObjectToJsonTransformer
* @see JacksonJsonObjectMapper
* @see Jackson2JsonObjectMapper
*/
public interface JsonObjectMapper<P> {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import java.io.Reader;
import java.io.Writer;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.json;
package org.springframework.integration.support.json;
import org.springframework.integration.Message;
import org.springframework.integration.mapping.OutboundMessageMapper;
import org.springframework.util.Assert;

View File

@@ -0,0 +1,4 @@
/**
* Provides classes supporting json.
*/
package org.springframework.integration.support.json;

View File

@@ -18,9 +18,9 @@ package org.springframework.integration.transformer;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.util.Assert;
/**

View File

@@ -20,8 +20,8 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.springframework.integration.json.JacksonJsonObjectMapperProvider;
import org.springframework.integration.json.JsonObjectMapper;
import org.springframework.integration.support.json.JacksonJsonObjectMapperProvider;
import org.springframework.integration.support.json.JsonObjectMapper;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

View File

@@ -2150,7 +2150,7 @@
<!-- TODO: Revert in the Spring Integration 3.1 or above after removing Jackson 1 backward compatibility
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.json.JsonObjectMapper" />
<tool:expected-type type="org.springframework.integration.support.json.JsonObjectMapper" />
</tool:annotation>
</xsd:appinfo>-->
</xsd:annotation>
@@ -2197,7 +2197,7 @@
<!-- TODO: Revert in the Spring Integration 3.1 or above after removing Jackson 1 backward compatibility
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.json.JsonObjectMapper" />
<tool:expected-type type="org.springframework.integration.support.json.JsonObjectMapper" />
</tool:annotation>
</xsd:appinfo>-->
</xsd:annotation>

View File

@@ -25,10 +25,10 @@ import java.util.Properties;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.context.NamedComponent;
/**
* @author Mark Fisher

View File

@@ -29,17 +29,23 @@ import java.util.UUID;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.message.MessageMatcher;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.JacksonJsonObjectMapperProvider;
import org.springframework.integration.support.json.JsonInboundMessageMapper;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
import org.springframework.integration.support.json.JsonObjectMapper;
/**
* @author Jeremy Grelle
* @author Mark Fisher
* @author Dave Syer
* @author Artem Bilan
* @author Gary Russell
*/
public class JsonInboundMessageMapperTests {
public abstract class AbstractJsonInboundMessageMapperTests {
private final JsonObjectMapper<?> mapper = JacksonJsonObjectMapperProvider.newInstance();
@@ -54,7 +60,7 @@ public class JsonInboundMessageMapperTests {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\",\"foo\":123,\"bar\":\"abc\"},\"payload\":\"myPayloadStuff\"}";
Message<String> expected = MessageBuilder.withPayload("myPayloadStuff").setHeader("foo", 123).setHeader("bar", "abc").build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
Message<?> result = mapper.toMessage(jsonMessage);
assertThat(result, sameExceptImmutableHeaders(expected));
}
@@ -63,7 +69,7 @@ public class JsonInboundMessageMapperTests {
public void testToMessageWithStringPayload() throws Exception {
String jsonMessage = "\"myPayloadStuff\"";
String expected = "myPayloadStuff";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
mapper.setMapToPayload(true);
Message<?> result = mapper.toMessage(jsonMessage);
assertEquals(expected, result.getPayload());
@@ -75,7 +81,7 @@ public class JsonInboundMessageMapperTests {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\",\"foo\":123,\"bar\":\"abc\"},\"payload\":" + getBeanAsJson(bean) + "}";
Message<TestBean> expected = MessageBuilder.withPayload(bean).setHeader("foo", 123).setHeader("bar", "abc").build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class, getParser());
Message<?> result = mapper.toMessage(jsonMessage);
assertThat(result, sameExceptImmutableHeaders(expected));
}
@@ -84,7 +90,7 @@ public class JsonInboundMessageMapperTests {
public void testToMessageWithBeanPayload() throws Exception {
TestBean expected = new TestBean();
String jsonMessage = getBeanAsJson(expected);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class, getParser());
mapper.setMapToPayload(true);
Message<?> result = mapper.toMessage(jsonMessage);
assertEquals(expected, result.getPayload());
@@ -96,7 +102,7 @@ public class JsonInboundMessageMapperTests {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\", \"myHeader\":" + getBeanAsJson(bean) + "},\"payload\":\"myPayloadStuff\"}";
Message<String> expected = MessageBuilder.withPayload("myPayloadStuff").setHeader("myHeader", bean).build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
Map<String, Class<?>> headerTypes = new HashMap<String, Class<?>>();
headerTypes.put("myHeader", TestBean.class);
mapper.setHeaderTypes(headerTypes);
@@ -110,7 +116,7 @@ public class JsonInboundMessageMapperTests {
String jsonMessage = "{\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\",\"foo\":123,\"bar\":\"abc\"},\"payload\":[\"myPayloadStuff1\",\"myPayloadStuff2\",\"myPayloadStuff3\"]}";
List<String> expectedList = Arrays.asList("myPayloadStuff1", "myPayloadStuff2", "myPayloadStuff3");
Message<List<String>> expected = MessageBuilder.withPayload(expectedList).setHeader("foo", 123).setHeader("bar", "abc").build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(new ParameterizedTypeReference<List<String>>(){}.getType());
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(new ParameterizedTypeReference<List<String>>(){}.getType(), getParser());
Message<?> result = mapper.toMessage(jsonMessage);
assertThat(result, sameExceptImmutableHeaders(expected));
}
@@ -123,7 +129,7 @@ public class JsonInboundMessageMapperTests {
String jsonMessage = "{\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\",\"foo\":123,\"bar\":\"abc\"},\"payload\":[" + getBeanAsJson(bean1) + "," + getBeanAsJson(bean2) + "]}";
List<TestBean> expectedList = Arrays.asList(bean1, bean2);
Message<List<TestBean>> expected = MessageBuilder.withPayload(expectedList).setHeader("foo", 123).setHeader("bar", "abc").build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(new ParameterizedTypeReference<List<TestBean>>(){}.getType());
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(new ParameterizedTypeReference<List<TestBean>>(){}.getType(), getParser());
Message<?> result = mapper.toMessage(jsonMessage);
assertThat(result, sameExceptImmutableHeaders(expected));
}
@@ -133,7 +139,7 @@ public class JsonInboundMessageMapperTests {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"payload\":\"myPayloadStuff\",\"headers\":{\"timestamp\":1,\"id\":\"" + id + "\",\"foo\":123,\"bar\":\"abc\"}}";
Message<String> expected = MessageBuilder.withPayload("myPayloadStuff").setHeader("foo", 123).setHeader("bar", "abc").build();
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
Message<?> result = mapper.toMessage(jsonMessage);
assertThat(result, sameExceptImmutableHeaders(expected));
}
@@ -141,7 +147,7 @@ public class JsonInboundMessageMapperTests {
@Test
public void testToMessageInvalidFormatPayloadNoHeaders() throws Exception {
String jsonMessage = "{\"payload\":\"myPayloadStuff\"}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
try {
mapper.toMessage(jsonMessage);
fail();
@@ -155,7 +161,7 @@ public class JsonInboundMessageMapperTests {
public void testToMessageInvalidFormatHeadersNoPayload() throws Exception {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"$timestamp\":1,\"$id\":\"" + id + "\"}}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
try {
mapper.toMessage(jsonMessage);
fail();
@@ -169,7 +175,7 @@ public class JsonInboundMessageMapperTests {
public void testToMessageInvalidFormatHeadersAndStringPayloadWithMapToPayload() throws Exception {
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"$timestamp\":1,\"$id\":\"" + id + "\"},\"payload\":\"myPayloadStuff\"}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
mapper.setMapToPayload(true);
try {
mapper.toMessage(jsonMessage);
@@ -185,7 +191,7 @@ public class JsonInboundMessageMapperTests {
TestBean bean = new TestBean();
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"$timestamp\":1,\"$id\":\"" + id + "\"},\"payload\":" + getBeanAsJson(bean) + "}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(TestBean.class, getParser());
mapper.setMapToPayload(true);
try {
mapper.toMessage(jsonMessage);
@@ -201,7 +207,7 @@ public class JsonInboundMessageMapperTests {
TestBean bean = new TestBean();
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"$timestamp\":1,\"$id\":\"" + id + "\"},\"payload\":" + getBeanAsJson(bean) + "}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(Long.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(Long.class, getParser());
try {
mapper.toMessage(jsonMessage);
fail();
@@ -216,7 +222,7 @@ public class JsonInboundMessageMapperTests {
TestBean bean = new TestBean();
UUID id = UUID.randomUUID();
String jsonMessage = "{\"headers\":{\"$timestamp\":1,\"$id\":\"" + id + "\",\"myHeader\":" + getBeanAsJson(bean) + "},\"payload\":\"myPayloadStuff\"}";
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper mapper = new JsonInboundMessageMapper(String.class, getParser());
Map<String, Class<?>> headerTypes = new HashMap<String, Class<?>>();
headerTypes.put("myHeader", Long.class);
mapper.setHeaderTypes(headerTypes);
@@ -234,4 +240,5 @@ public class JsonInboundMessageMapperTests {
return mapper.toJson(bean);
}
protected abstract JsonMessageParser<?> getParser();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -21,17 +21,22 @@ import static org.junit.Assert.assertThat;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.MessageMatcher;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.support.json.JsonInboundMessageMapper;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
import org.springframework.integration.support.json.JsonOutboundMessageMapper;
/**
* @author Jeremy Grelle
* @author Gary Russell
*/
public class JsonSymmetricalMessageMappingTests {
public abstract class AbstractJsonSymmetricalMessageMappingTests {
@Factory
public static Matcher<Message<?>> sameExceptImmutableHeaders(Message<?> operand) {
@@ -48,14 +53,14 @@ public class JsonSymmetricalMessageMappingTests {
String outboundJson = outboundMapper.fromMessage(testMessage);
JsonInboundMessageMapper inboundMapper = new JsonInboundMessageMapper(String.class);
JsonInboundMessageMapper inboundMapper = new JsonInboundMessageMapper(String.class, getParser());
Message<?> result = inboundMapper.toMessage(outboundJson);
assertThat(result, sameExceptImmutableHeaders(testMessage));
outboundJson = outboundMapper.fromMessage(result);
}
protected abstract JsonMessageParser<?> getParser();
private static class TestNamedComponent implements NamedComponent {
private final int id;

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.json;
import org.springframework.integration.support.json.Jackson2JsonMessageParser;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class Jackson2JsonInboundMessageMapperTests extends AbstractJsonInboundMessageMapperTests {
@Override
protected JsonMessageParser<?> getParser() {
return new Jackson2JsonMessageParser();
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.json;
import org.springframework.integration.support.json.Jackson2JsonMessageParser;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class Jackson2JsonSymmetricalMessageMappingTests extends AbstractJsonSymmetricalMessageMappingTests {
@Override
protected JsonMessageParser<?> getParser() {
return new Jackson2JsonMessageParser();
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.json;
import org.springframework.integration.support.json.JacksonJsonMessageParser;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class JacksonJsonInboundMessageMapperTests extends AbstractJsonInboundMessageMapperTests {
@Override
protected JsonMessageParser<?> getParser() {
return new JacksonJsonMessageParser();
}
}

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.json;
import org.springframework.integration.support.json.JacksonJsonMessageParser;
import org.springframework.integration.support.json.JsonInboundMessageMapper.JsonMessageParser;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class JacksonJsonSymmetricalMessageMappingTests extends AbstractJsonSymmetricalMessageMappingTests {
@Override
protected JsonMessageParser<?> getParser() {
return new JacksonJsonMessageParser();
}
}

View File

@@ -29,9 +29,10 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.support.json.JsonOutboundMessageMapper;
/**
* @author Jeremy Grelle

View File

@@ -24,6 +24,7 @@ import org.codehaus.jackson.JsonParser.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.Message;
@@ -31,6 +32,9 @@ import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
import org.springframework.integration.support.json.JsonObjectMapper;
import org.springframework.integration.support.json.JsonObjectMapperAdapter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -22,6 +22,8 @@ import org.codehaus.jackson.JsonParser.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.springframework.integration.support.json.JacksonJsonObjectMapper;
/**
* @author Mark Fisher
* @author Artem Bilan

View File

@@ -28,6 +28,7 @@ import org.codehaus.jackson.JsonGenerator.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.Message;
@@ -35,6 +36,8 @@ import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
import org.springframework.integration.support.json.JsonObjectMapperAdapter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

View File

@@ -26,10 +26,12 @@ import java.util.regex.Pattern;
import org.codehaus.jackson.JsonGenerator.Feature;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.JacksonJsonObjectMapper;
/**
* @author Mark Fisher

View File

@@ -24,6 +24,7 @@ import java.util.Properties;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import org.hamcrest.Matcher;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanFactory;
@@ -39,11 +40,11 @@ import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.channel.MessagePublishingErrorHandler;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.ErrorHandler;

View File

@@ -46,6 +46,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.SimpleTypeConverter;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -56,11 +57,11 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.context.NamedComponent;
/**
* @author Oleg Zhurakousky

View File

@@ -30,10 +30,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.AbstractApplicationContext;
@@ -44,10 +44,11 @@ import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.jdbc.config.JdbcTypesEnum;
import org.springframework.integration.jdbc.storedproc.User;
import org.springframework.integration.json.JsonInboundMessageMapper;
import org.springframework.integration.json.JsonOutboundMessageMapper;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.json.Jackson2JsonMessageParser;
import org.springframework.integration.support.json.JsonInboundMessageMapper;
import org.springframework.integration.support.json.JsonOutboundMessageMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlReturnType;
import org.springframework.test.annotation.DirtiesContext;
@@ -159,7 +160,7 @@ public class StoredProcOutboundGatewayWithSpelIntegrationTests {
assertNotNull(resultMessage);
Object resultPayload = resultMessage.getPayload();
assertTrue(resultPayload instanceof String);
Message<?> message = new JsonInboundMessageMapper(String.class).toMessage((String) resultPayload);
Message<?> message = new JsonInboundMessageMapper(String.class, new Jackson2JsonMessageParser()).toMessage((String) resultPayload);
assertEquals(testMessage.getPayload(), message.getPayload());
assertEquals(testMessage.getHeaders().get("FOO"), message.getHeaders().get("FOO"));
Mockito.verify(clobSqlReturnType).getTypeValue(Mockito.any(CallableStatement.class),

View File

@@ -32,11 +32,11 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.jms.DefaultJmsHeaderMapper;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.context.NamedComponent;
/**
* @author Oleg Zhurakousky

View File

@@ -21,9 +21,9 @@ import java.rmi.registry.Registry;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.remoting.rmi.RmiServiceExporter;
import org.springframework.remoting.support.RemoteInvocationExecutor;
import org.springframework.util.Assert;

View File

@@ -26,7 +26,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.util.Assert;

View File

@@ -34,9 +34,9 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.support.context.NamedComponent;
/**
* @author Mark Fisher

View File

@@ -24,6 +24,7 @@ import java.util.Properties;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import org.hamcrest.Matcher;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanFactory;
@@ -39,11 +40,11 @@ import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.channel.MessagePublishingErrorHandler;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.ErrorHandler;