GH-1228 Type resolvers cleanup
- moved OriginalContentTypeResolver to avro module - removed StringConvertingContentTypeResolver as it is no longer referenced anywhere - deprecated KryoMessageConverter Resolves #1228
This commit is contained in:
@@ -62,7 +62,6 @@ import org.springframework.messaging.handler.annotation.support.PayloadArgumentR
|
||||
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolverComposite;
|
||||
import org.springframework.messaging.handler.invocation.InvocableHandlerMethod;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
@@ -279,7 +278,6 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
DirectChannel moduleOutputChannel = createBindableChannel("output", outputBindingProperties);
|
||||
|
||||
BindingProperties inputBindingProperties = createConsumerBindingProperties(createConsumerProperties());
|
||||
//inputBindingProperties.setContentType("tex/plain");
|
||||
DirectChannel moduleInputChannel = createBindableChannel("input", inputBindingProperties);
|
||||
|
||||
Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("foo%s0y",
|
||||
@@ -749,11 +747,6 @@ public abstract class AbstractBinderTests<B extends AbstractTestBinder<? extends
|
||||
consumerBinding.unbind();
|
||||
}
|
||||
|
||||
private static boolean equalTypeAndSubType(MimeType m1, MimeType m2) {
|
||||
return m1 != null && m2 != null && m1.getType().equalsIgnoreCase(m2.getType())
|
||||
&& m1.getSubtype().equalsIgnoreCase(m2.getSubtype());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // it is used via reflection
|
||||
private Station echoStation(Station station) {
|
||||
return station;
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.apache.avro.specific.SpecificDatumReader;
|
||||
import org.apache.avro.specific.SpecificDatumWriter;
|
||||
import org.apache.avro.specific.SpecificRecord;
|
||||
|
||||
import org.springframework.cloud.stream.binder.OriginalContentTypeResolver;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-2018 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.
|
||||
@@ -14,11 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.stream.binder;
|
||||
package org.springframework.cloud.stream.schema.avro;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.springframework.cloud.stream.binder.BinderHeaders;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.converter.ContentTypeResolver;
|
||||
import org.springframework.util.MimeType;
|
||||
@@ -30,7 +31,7 @@ import org.springframework.util.MimeType;
|
||||
* returns the contentType
|
||||
*
|
||||
*/
|
||||
public class OriginalContentTypeResolver implements ContentTypeResolver {
|
||||
class OriginalContentTypeResolver implements ContentTypeResolver {
|
||||
|
||||
private ConcurrentMap<String, MimeType> mimeTypeCache = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -56,8 +56,6 @@ public abstract class AbstractBinder<T, C extends ConsumerProperties, P extends
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
protected final StringConvertingContentTypeResolver contentTypeResolver = new StringConvertingContentTypeResolver();
|
||||
|
||||
private volatile AbstractApplicationContext applicationContext;
|
||||
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015 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.cloud.stream.binder;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.converter.DefaultContentTypeResolver;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* A {@link DefaultContentTypeResolver} that can parse String values.
|
||||
*
|
||||
* @author David Turanski
|
||||
*/
|
||||
public class StringConvertingContentTypeResolver extends DefaultContentTypeResolver {
|
||||
|
||||
private ConcurrentMap<String, MimeType> mimeTypeCache = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public MimeType resolve(MessageHeaders headers) {
|
||||
return resolve((Map<String, Object>) headers);
|
||||
}
|
||||
|
||||
public MimeType resolve(Map<String, Object> headers) {
|
||||
MimeType mimeType = null;
|
||||
Object value = headers.get(MessageHeaders.CONTENT_TYPE);
|
||||
if (value instanceof MimeType) {
|
||||
mimeType = (MimeType) value;
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
mimeType = mimeTypeCache.get(value);
|
||||
if (mimeType == null) {
|
||||
String valueAsString = (String) value;
|
||||
mimeType = MimeType.valueOf(valueAsString);
|
||||
mimeTypeCache.put(valueAsString, mimeType);
|
||||
}
|
||||
}
|
||||
return mimeType != null ? mimeType : getDefaultMimeType();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,9 @@ import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* @author Vinicius Carvalho
|
||||
* @deprecated as of 2.0 all language specific type converters (kryo, java etc) are deprecated and won't be supported in the future.
|
||||
*/
|
||||
@Deprecated
|
||||
public class KryoMessageConverter implements SmartMessageConverter {
|
||||
|
||||
protected final KryoPool pool;
|
||||
|
||||
Reference in New Issue
Block a user