INTSAMPLES-127 Polishing
- PR Comments - Switch to Jackson2 - Fix oxm config Polishing INTSAMPLES-127 Update to SI 4.0.0.RC1 INTSAMPLES-127 Remove Servlet Dependency travel sample; see INT-3350. INTSAMPLES-127 Update Samples to SI 4.0.0 JIRA: https://jira.spring.io/browse/INTSAMPLES-127 Created `maint` branch for ongoing SI 3.0.x samples.
This commit is contained in:
committed by
Artem Bilan
parent
c5b1ace70f
commit
cc579226d6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package org.springframework.integration.samples.rest.json;
|
||||
|
||||
import org.codehaus.jackson.map.AnnotationIntrospector;
|
||||
import org.codehaus.jackson.map.DeserializationConfig;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.DeserializationConfig;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
|
||||
|
||||
|
||||
/**
|
||||
* JaxbJacksonObjectMapper.java: This is the custom JAXB JSON ObjectMapper
|
||||
@@ -27,22 +28,26 @@ import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
|
||||
* http://hillert.blogspot.com/2011/01/marshal-json-data-using-jackson-in.html.
|
||||
* I modified a little bit to use the latest {@link DeserializationConfig} API
|
||||
* instead of deprecated ones.
|
||||
* <p> *
|
||||
* <p>
|
||||
* Updated to Jackson2.
|
||||
* <p>
|
||||
* @author Vigil Bose
|
||||
* @author Gary Russell
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class JaxbJacksonObjectMapper extends ObjectMapper {
|
||||
|
||||
/**
|
||||
* Annotation introspector to use for serialization process
|
||||
* Annotation introspector to use for serialization process
|
||||
* is configured separately for serialization and deserialization purposes
|
||||
*/
|
||||
public JaxbJacksonObjectMapper() {
|
||||
final AnnotationIntrospector introspector
|
||||
= new JacksonAnnotationIntrospector();
|
||||
super.getDeserializationConfig()
|
||||
.withAnnotationIntrospector(introspector);
|
||||
.with(introspector);
|
||||
super.getSerializationConfig()
|
||||
.withAnnotationIntrospector(introspector);
|
||||
|
||||
.with(introspector);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -17,17 +17,18 @@ package org.springframework.integration.samples.rest.json.view;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
|
||||
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
|
||||
|
||||
/**
|
||||
* ExtendedMappingJacksonJsonView.java: This class extends the Spring's MappingJacksonJsonView
|
||||
* <p>
|
||||
* Note: The source code for this class is taken from the forum posted by AhungerArtist
|
||||
* at http://forum.springsource.org/archive/index.php/t-84006.html
|
||||
* </p>
|
||||
* <p>
|
||||
* @author Vigil Bose
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ExtendedMappingJacksonJsonView extends MappingJacksonJsonView {
|
||||
public class ExtendedMappingJacksonJsonView extends MappingJackson2JsonView {
|
||||
|
||||
@SuppressWarnings({"rawtypes" })
|
||||
@Override
|
||||
@@ -36,10 +37,10 @@ public class ExtendedMappingJacksonJsonView extends MappingJacksonJsonView {
|
||||
if (!(result instanceof Map)){
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Map map = (Map) result;
|
||||
if (map.size() == 1){
|
||||
return map.values().toArray()[0];
|
||||
return map.values().toArray()[0];
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.samples.rest.domain.Employee;
|
||||
import org.springframework.integration.samples.rest.domain.EmployeeList;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<oxm:jaxb2-marshaller id="marshaller" contextPath="org.springframework.integration.samples.rest.domain" />
|
||||
<oxm:jaxb2-marshaller id="marshaller" context-path="org.springframework.integration.samples.rest.domain" />
|
||||
|
||||
<int:service-activator id="employeeServiceActivator"
|
||||
input-channel="employeeSearchRequest"
|
||||
|
||||
Reference in New Issue
Block a user