Created
October 27, 2020 19:36
-
-
Save NutterzUK/8c908e8d64b9410f055b5b76799c26b1 to your computer and use it in GitHub Desktop.
This file contains 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.example.demo; | |
import org.aspectj.lang.JoinPoint; | |
import org.aspectj.lang.annotation.Aspect; | |
import org.aspectj.lang.annotation.Before; | |
import org.aspectj.lang.annotation.Pointcut; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.stereotype.Component; | |
@Aspect | |
@Component | |
public class MyAspect { | |
private static final Logger LOG = LoggerFactory.getLogger(MyAspect.class); | |
@Pointcut("within(com.example.demo..*)") | |
private void everythingInMyApplication() {} | |
@Before("com.example.demo.MyAspect.everythingInMyApplication()") | |
public void logMethodName(JoinPoint joinPoint) { | |
LOG.info("Called {}", joinPoint.getSignature().getName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment