Skip to content

Instantly share code, notes, and snippets.

Created Dec 22, 2010
What would you like to do?
support for VRaptor2's @out annotation
public @interface Out {
@Intercepts(after=ExecuteMethodInterceptor.class, before=ForwardToDefaultViewInterceptor.class)
public class OutAnnotationInterceptor implements Interceptor {
public OutAnnotationInterceptor(Result result) {
this.result = result;
public boolean accepts(ResourceMethod method) { return true; }
public void intercept(InterceptorStack stack, ResourceMethod method, Object instance) {
List<Field> fields = new Mirror().on(ResourceMethod.class).reflectAll().fields();
for (Field field : fields) {
if (field.isAnnotationPresent(Out.class))
result.include(field.getName(), new Mirror().on(instance).get().field(field));
}, instance);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment