Reputation: 35
When I call fooMethod, I want to process first class annotation (with First.class - in my project this checks if user is logged) and then method annotation (with Second.class - in my project this checks if uses has desired rights to access this specific method. So I need to ensure user is logged first). Is there a way to do that?
@With(First.class)
public class Foo{
@With(Second.class)
public static void fooMethod(){
}
}
Also I wonder why custum action ignores annotation. Code below doesn't process anotation @With(First.class).
public class Foo2 extends Action<CustomAnnotation> {
@Override
@With(First.class)
public Promise<Result> call(Http.Context context) throws Throwable {
return delegate.call(context);
}
}
}
Similar unanswered question: Java + Play Framework 2 with nested action compositions in the same class
Upvotes: 2
Views: 1035
Reputation: 238
In Play 2.4 there appears to be an option for this from the docs here:
Note: If you want the action composition annotation(s) put on a Controller class to be executed before the one(s) put on action methods set play.http.actionComposition.controllerAnnotationsFirst = true in application.conf. However, be aware that if you use a third party module in your project it may rely on a certain execution order of its annotations.
The note is only present in the 2.4 docs, so presumably it doesn't work in previous versions.
Upvotes: 1
Reputation: 4823
It looks like at least in Java 8 you have an order in annotation of the same kind: Java Annotations Reflection Ordering.
Upvotes: 0