Jackson Deserializer not being called for @*Param

做~自己de王妃 提交于 2019-12-25 04:23:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!