Hi all,
I tried to apply AOP to Struts2 action classes.
My configurations are:
Code:
<aop:aspectj-autoproxy proxy-target-class="true"/>

<bean id="actionClassAspect" class="com.rpm.application.profiling.ActionClassAspect"/>

<aop:config>
	<aop:pointcut id="actionClassPointcut" expression="execution(public * com.rpm..action.*.*(..))
		and !execution(public * com.rpm..action.*.get*(..))
		and !execution(public * com.rpm..action.*.set*(..))
		and !within(com.rpm..profiling.*)"/>
			 
	<aop:aspect id="actionAspect" ref="actionClassAspect">
		<aop:around method="doAspect" pointcut-ref="actionClassPointcut"/>
	</aop:aspect>
</aop:config>
my action class is:
Code:
package com.rpm.application.common.web.action;

import com.opensymphony.xwork2.ActionSupport;

public class ApplicationLoginAction extends ActionSupport {
	private String userID, password;

	@Override
	public String execute() throws Exception {
		try {
			//validation logic
			System.out.println("Login success");
			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;
	}
}
my aspect is:
Code:
package com.rpm.application.profiling;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public abstract class ActionClassAspect {
	public Object doAspect(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
		long start = System.currentTimeMillis();
		Object returnValue = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs());
		long end = System.currentTimeMillis();
		System.out.println(" " + proceedingJoinPoint.getTarget().getClass() + " KIND:" + proceedingJoinPoint.getSignature().toShortString() + " TIME: " + (end - start));
		return returnValue;
	}
}
When I executing this application on tomcat6.x server AOP is not applied to that action class.