package roseindia.net.main;

import org.springframework.aop.Advisor;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;

import roseindia.net.advice.SimpleAdvice;
import roseindia.net.bean.StudentBean;

public class MainClaz {
	public static void main(String args[]) {
		StudentBean studentBean = new StudentBean();
		AspectJExpressionPointcut aspectJExpressionPointcut = new AspectJExpressionPointcut();
		aspectJExpressionPointcut
				.setExpression("execution(* roseindia.net.bean..*.get*(..))");
		SimpleAdvice advice = new SimpleAdvice();
		Advisor advisor = new DefaultPointcutAdvisor(aspectJExpressionPointcut,
				advice);
		ProxyFactory proxyFactory = new ProxyFactory();
		proxyFactory.setTarget(studentBean);
		proxyFactory.addAdvisor(advisor);
		StudentBean proxy = (StudentBean) proxyFactory.getProxy();
		System.out.println(proxy.getName());
		proxy.setName("Ram");
		System.out.println(proxy.getRoll());
		System.out.println(proxy.getName());
	}
}
