下面列出了javax.ws.rs.ext.ReaderInterceptorContext#getProperty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
Object object = context.proceed();
if (context.getProperty(EMPTY_PAYLOAD) != TRUE) {
return object;
}
if (object instanceof Collection) {
Collection<?> collection = (Collection<?>) object;
if (collection.isEmpty()) {
throw new EmptyPayloadException();
}
} else if (object instanceof Map) {
Map<?, ?> map = (Map<?, ?>) object;
if (map.isEmpty()) {
throw new EmptyPayloadException();
}
} else if (object == null) {
throw new EmptyPayloadException();
}
return object;
}
protected boolean isCacheControlValid(final ReaderInterceptorContext context,
final CacheControl responseControl) {
boolean valid =
responseControl != null && !responseControl.isNoCache() && !responseControl.isNoStore();
if (valid) {
String clientHeader =
(String)context.getProperty(CacheControlClientRequestFilter.CLIENT_CACHE_CONTROL);
CacheControl clientControl = clientHeader == null ? null : CacheControl.valueOf(clientHeader);
if (clientControl != null && clientControl.isPrivate() != responseControl.isPrivate()) {
valid = false;
}
}
return valid;
}