<file_sep>package com.anuj.springboot.aop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

import com.anuj.springboot.aop.model.Strudent;

@SpringBootApplication
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class SpringBootAopIntegrationApplication implements CommandLineRunner{

	@Autowired 
	Strudent s;
	
	public static void main(String[] args) {
		SpringApplication.run(SpringBootAopIntegrationApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		
		System.out.println("Inside run");
		System.out.println("To test git");
		System.out.println("To test git clone");
		s.setName("<NAME>");
		s.getName();
		s.setAge("25");
		
	}

}
<file_sep>package com.anuj.springboot.aop.aspectj;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AspectProgram {
	
	@Before(value = "execution(* setName(..)) and args(name)")
	public void beforeAdvice(JoinPoint joinPoint,String name) {
		System.out.println(" before advice executed name:"+name+"joinPoint:"+joinPoint);
	}
	
	@After(value = "execution(* setName(..)) and args(name)")
	public void afterAdvice(JoinPoint joinPoint,String name) {
		System.out.println(" After advice executed name:"+name);
	}
	
	@Around(value = "execution(* setAge(..)) and args(age)")
	public void arroundAdvice(ProceedingJoinPoint procedingJointPoint,String age) throws Throwable {
		System.out.println("Arround advice getting exceited before method invocation age:"+age);
		procedingJointPoint.proceed();
		System.out.println("Arround advice getting exceuted after method invocaton");
	}
	
	@Before(value = "allGetter()")
	public void berforeGetterAdvice() {
		System.out.println("Inside getter advice");
	}
	
	@Pointcut(value = "execution(* setName(..))")
	public void allGetter() {
		
	}
}
