Hi all
I am trying to implemenet AspectJ in my application.
My application have package containing all the beans(
mypackage.beans). What I want to do is whenever I the getters of the beans are
called from the jsp it should call the advice and return the formatted value.
What I have done is:
STEP1: Created an aspect :
public aspect Example{
pointcut
requiredField() : call(*mypackage.beans.*get*(..));
before() :
requiredField() {
System.out.println("entering: " + thisJoinPoint);
System.out.println(" at: " +
thisJoinPoint.getSourceLocation());
}
}\
STEP 2: I am usning ant in the project to build. So I first
precompiled by jsp through JspC. And then I am trying to compile these jsp
servlets through iajc.
<iajc
source="${javac.source}"
deprecation="false"
debug="${javac.debug}"
debuglevel = "${javac.debuglevel}"
destdir="@{output.dir}"
classpathref="@{classpath.pathref}"
fork = "true"
maxmem ="512m">
<sourceroots>
<path
refid="@{src.pathref}" /> <!—path for
the Java source-->
<path
location="jasper_src" /> <!--path for
the jsp servlets source-->
</sourceroots>
</iajc>
My problem is that I am using JSTL in my JSP’s and
whenever I am fetching value from my bean in my jsp I am using tags rather than
writing java code in scriptlets to fetch the data. And the jsp compiler
converts these tags into :
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${bean.value}",
java.lang.Object.class, (PageContext)_jspx_page_context, null, false));
This function gets the value from the bean by calling the
getter function only but all this is done internally.Due to this the jointpoint
is not applied here. Also this functions gets the vale from the bean at runtime
so I am not able to identify the jointpoint.
Kindly let me know how to overcome this problem and my advice
is called whenever jsp gets the value from bean.
Thanks in Advance.
Saurabh