[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] AspectJ, Annotations and JSP
|
I have a bunch of JSPs that all have common init methods.
<%!
public void jspInit() {
runCommonCode();
}
%>
I could put this at the top of each JSP. But that got me wondering if there was a better way to do this with AspectJ. In the past I have used and loved @AspectJ annotated style. I have also used annotations on classes and methods to make pattern matching a lot easier. I would like to do that here too. If I could annotate the JSP class, I could add the jspInit() method to all JSPs with the annotation. Wallah!
Of course, there is a problem. The JSP is run through the JSP compiler. So there appears to be no way to put an annotation on the resulting JSP class. If there is a way to annotate a JSP class, I don't know how. Assuming I still want to use annotations I would have to do this:
<%!
@commonJspInit
public void jspInit() {}
%>
This does not get me much. I still have to write the method. I could fall back to regular pattern matching without the annotation within the @Pointcut. But This could potentially get really complex since I have JSPs all over the place. And some JSPs need this while others do not.
Any ideas?