org.codehaus.jackson.jaxrs.JacksonJsonProvider.rej Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ehcache Show documentation
Show all versions of ehcache Show documentation
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
***************
*** 15,22 ****
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.type.ClassKey;
import org.codehaus.jackson.map.util.ClassUtil;
import org.codehaus.jackson.map.util.JSONPObject;
--- 15,25 ----
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.DeserializationConfig;
+ import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
+ import org.codehaus.jackson.map.ObjectWriter;
import org.codehaus.jackson.map.SerializationConfig;
+ import org.codehaus.jackson.map.annotate.JsonView;
import org.codehaus.jackson.map.type.ClassKey;
import org.codehaus.jackson.map.util.ClassUtil;
import org.codehaus.jackson.map.util.JSONPObject;
***************
*** 518,530 ****
}
}
}
- // [JACKSON-245] Allow automatic JSONP wrapping
- if (_jsonpFunctionName != null) {
- mapper.writeValue(jg, new JSONPObject(_jsonpFunctionName, value, rootType));
- } else if (rootType != null) {
- mapper.typedWriter(rootType).writeValue(jg, value);
} else {
- mapper.writeValue(jg, value);
}
}
--- 521,564 ----
}
}
}
+ Class> viewToUse = null;
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType().isAssignableFrom(JsonView.class)) {
+ JsonView jsonView = (JsonView) annotation;
+ Class>[] views = jsonView.value();
+ if (views.length > 1) {
+ StringBuilder s = new StringBuilder("Multiple JsonView's can not be used on a JAX-RS method. Got ");
+ for (int i = 0; i < views.length; i++) {
+ if (i > 0) {
+ s.append(", ");
+ }
+ s.append(views[i]);
+ }
+ throw new JsonMappingException(s.toString());
+ } else {
+ viewToUse = views[0];
+ }
+ }
+ }
+ if (viewToUse != null) {
+ ObjectWriter viewWriter = mapper.viewWriter(viewToUse);
+ // [JACKSON-245] Allow automatic JSONP wrapping
+ if (this._jsonpFunctionName != null) {
+ viewWriter.writeValue(jg, new JSONPObject(this._jsonpFunctionName, value, rootType));
+ } else if (rootType != null) {
+ mapper.typedWriter(rootType).withView(viewToUse).writeValue(jg, value);
+ } else {
+ viewWriter.writeValue(jg, value);
+ }
} else {
+ // [JACKSON-245] Allow automatic JSONP wrapping
+ if (this._jsonpFunctionName != null) {
+ mapper.writeValue(jg, new JSONPObject(this._jsonpFunctionName, value, rootType));
+ } else if (rootType != null) {
+ mapper.typedWriter(rootType).writeValue(jg, value);
+ } else {
+ mapper.writeValue(jg, value);
+ }
}
}