我的服务返回响应对象基于writeTo方法中的计算我想要设置http状态。能否请你帮忙我如何设置http状态。
@Provider
@Produces(MediaType.APPLICATION_XML)
public class ResponseWriter implements MessageBodyWriter<RespObject> {
@Override
public long getSize(RespObject resp, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType) {
return -1;
}
@Override
public void writeTo(RespObject resp, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
// Based on resp type object i want set http status here
}
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return true;
}
}