views:

34

answers:

0

Hi all, I am new to Spring aop and I decided to use aop to track my Struts2 Action class execution time. I have done the following things. But while running the application setter method of the action class is not called. Here is my code. xml configuration:

<aop:aspectj-autoproxy/>

 <bean id="myAspect" class="abc.xyz.ActionClassAspect"/>

 <aop:config>
  <aop:pointcut id="actionClassPointcut" expression="execution(public * abc.xyz.action.*.*(..))
 and !execution(public * abc.xyz.action.*Action.get*(..))
 and !execution(public * abc.xyz.action.*Action.set*(..))"/>

   <aop:around pointcut-ref="actionClassPointcut" method="doActionClassProfilling"/>
  </aop:aspect>
 </aop:config>

Aspect:

    public Object doActionClassProfilling(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
  long start = System.currentTimeMillis();
  Object returnValue = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs());
  long end = System.currentTimeMillis();
  System.out.println(proceedingJoinPoint.getClass()+" TIME: "+(end-start));
  return returnValue;
 }
Action Class:

    private String userID, password;
 @Override
 public String execute() throws Exception {
  try {
   LoginService loginService = LoginService.getInstance();;
   UserProfile userProfile = loginService.validateUser(userID, password);
   Map<String, Object> sessionMap = ActionContext.getContext().getSession();
   sessionMap.put("USER_PROFILE", userProfile);
   return SUCCESS;
  } catch(Exception e) {
   return ERROR;
  }
 }
 public String getUserID() {
  return userID;
 }
 public void setUserID(String userID) {
  this.userID = userID;
 }
 public String getPassword() {
  return password;
 }
 public void setPassword(String password) {
  this.password = password;
 }

Thanks in advance.