This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.annotation.Pointcut; | |
| public class CommonJoinPointConfig { | |
| //下面這個data層的Method的QualifedName: | |
| //com.pig.spring.springaop.springaop.aspect.CommonJoinPointConfig.dataLayerExecution() | |
| @Pointcut("execution(* com.pig.spring.springaop.springaop.data.*.*(..))") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.JoinPoint; | |
| import org.aspectj.lang.annotation.Aspect; | |
| import org.aspectj.lang.annotation.Before; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.context.annotation.Configuration; | |
| @Aspect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.ProceedingJoinPoint; | |
| import org.aspectj.lang.annotation.Around; | |
| import org.aspectj.lang.annotation.Aspect; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.context.annotation.Configuration; | |
| @Aspect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.JoinPoint; | |
| import org.aspectj.lang.annotation.After; | |
| import org.aspectj.lang.annotation.AfterReturning; | |
| import org.aspectj.lang.annotation.Aspect; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import org.springframework.context.annotation.Configuration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.annotation.Pointcut; | |
| public class CommonJoinPointConfig { | |
| //下面這個data層的Method的QualifedName: | |
| //com.pig.spring.springaop.springaop.aspect.CommonJoinPointConfig.dataLayerExecution() | |
| @Pointcut("execution(* com.pig.spring.springaop.springaop.data.*.*(..))") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| //Methods | |
| //Runtime | |
| public @interface TrackTime { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import java.lang.annotation.ElementType; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.RetentionPolicy; | |
| import java.lang.annotation.Target; | |
| @Target(ElementType.METHOD) //指執行的時機指定在Method執行使用 | |
| @Retention(RetentionPolicy.RUNTIME)//運行時啟用 | |
| public @interface TrackTime { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.data; | |
| import org.springframework.stereotype.Repository; | |
| @Repository | |
| public class Dao1 { | |
| public String retriveSomething() { | |
| return "Dao1"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.data; | |
| import org.springframework.stereotype.Repository; | |
| import com.pig.spring.springaop.springaop.aspect.TrackTime; | |
| @Repository | |
| public class Dao1 { | |
| @TrackTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.springaop.springaop.aspect; | |
| import org.aspectj.lang.annotation.Pointcut; | |
| public class CommonJoinPointConfig { | |
| //com.pig.spring.springaop.springaop.aspect.CommonJoinPointConfig.dataLayerExecution() | |
| @Pointcut("execution(* com.pig.spring.springaop.springaop.data.*.*(..))") | |
| public void dataLayerExecution() {} | |