package ch.hsr.servicestoolkit;

import javax.ws.rs.ext.ContextResolver;

import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;

public class ObjectMapperContextResolver implements ContextResolver<ObjectMapper> {

	private final ObjectMapper mapper;

	public ObjectMapperContextResolver() {
		mapper = new ObjectMapper();
		mapper.registerModule(new Hibernate4Module());
		mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
		mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
	}

	@Override
	public ObjectMapper getContext(Class<?> type) {
		return mapper;
	}

}

@@ -255,71 +255,8 @@
 r;%0D%0A
-import com.fasterxml.jackson.databind.PropertyNamingStrategy;%0D%0A
 impo
@@ -574,111 +574,8 @@
 );%0D%0A
-%09%09mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);%0D%0A
 %09%09ma

remove underline naming strategy from mapper to resolve jackson/spring marhsalling mismatch