Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Implementing AspectJ in JSP with Tag libraries

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

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have
received this email in error please delete it and notify the sender immediately. Before opening any mail and
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------

Back to the top