I have an interface, for example
@NameBinding
@Retention(RetentionPolicy.RUNTIME)
public @interface AutoLogged {
boolean query() default false;
}
How can I get query
parameter in interceptor implementation?
@Provider
@AutoLogged
public class AutoLoggedInterceptor implements WriterInterceptor {
@Context
private ResourceInfo resourceInfo;
@Override
public void aroundWriteTo(final WriterInterceptorContext context)
throws IOException, WebApplicationException {
try {
final String methodName = this.resourceInfo.getResourceMethod().getName();
BasicAutoLoggedProducer.makeCall(methodName);
} catch (final Exception e) {
e.printStackTrace(System.err);
} finally {
context.proceed();
}
}
}
I can not find it in context.getPropertyNames. I see annotation AutoLogged
with getAnnotations method. How to retrieve parameter query
from interface?
You can simply do
Not exactly sure what you mean hear, but if you mean you want to set the value at runtime, I'm not really sure the purpose and not really sure how to do it. Hopefully you men "get" instead of "set" :-)