问题
Im trying to use JsonDeserialzer on a jax path parameter.
Here is my @BeanParam object,
@BeanParam
private CustomerWrapper reference;
@QueryParam("select")
private String select;
@QueryParam("count")
private boolean count;
@BeanParam
PaginationInfo paginationInfo;
@BeanParam
private SortingInfo sortingInfo;
@QueryParam("line")
private String line;
@QueryParam("typeCode")
private String typeCode;
class CustomReference {
@NotNull
@PathParam("profileReferenceId")
@Encoded
private String referenceId;
public CustomerReference(String referenceId) {
this.referenceId = referenceId;
}
public CustomeReference fromString() {
return new CustomerReference(Base64.decode(referenceId));
}
}
The referenceId
field is a base64 encoded string, to decode it, i am using a jsondeserializer.
However, i have read json messagereader does not work on jax @*params.
From another post, i figured this can be achieved by creating javax.ws.rs.ext.ParamConverterProvider
.
Example,
@Provider
public class TestClass implements ParamConverterProvider {
private Logger logger = LoggerFactory.getLogger(TestClass.class);
@Override
public <T> ParamConverter<T> getConverter(
Class<T> rawType, Type genericType, Annotation[] antns) {
logger.debug("rawtype " +rawType.getName());
for(Annotation a : antns) {
logger.debug("anotations " +a.annotationType().getName());
}
return null;
}
}
output:
[DEBUG] 31 Oct 2016 23:20:23,788 DEBUG [http-nio-8082-exec-1] TestClass - rawtype boolean
[DEBUG] 31 Oct 2016 23:20:23,788 DEBUG [http-nio-8082-exec-1] TestClass - anotations javax.ws.rs.QueryParam
why does this converter only recognize one queryparam and ignore the rest.
来源:https://stackoverflow.com/questions/40355065/jackson-deserializer-not-being-called-for-param