Skip to content

Instantly share code, notes, and snippets.

@orekyuu
Created March 17, 2016 06:45
Show Gist options
  • Save orekyuu/65c7c061f7d34c01f7e9 to your computer and use it in GitHub Desktop.
Save orekyuu/65c7c061f7d34c01f7e9 to your computer and use it in GitHub Desktop.
package com.example
import org.aspectj.lang.JoinPoint
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Before
import org.aspectj.lang.reflect.MethodSignature
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.stereotype.Component
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
@SpringBootApplication
@Controller
open class DemoApplication {
@ResponseBody
@RequestMapping("/")
open fun hello(): String {
println("/hello")
return "hello"
}
}
@Aspect
@Component
open class PrintlnAspect {
@Before("execution(public String com.example.DemoApplication.hello())")
open fun around(joinPoint: JoinPoint) {
println("before call: ${joinPoint.signature}")
}
}
fun main(args: Array<String>) {
SpringApplication.run(DemoApplication::class.java, *args)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment