Created
November 5, 2016 11:56
-
-
Save orekyuu/74c0009e3010041c13818753aec0e435 to your computer and use it in GitHub Desktop.
throw_orekyuu
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.example; | |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| import org.springframework.stereotype.Controller; | |
| import org.springframework.web.bind.annotation.GetMapping; | |
| import org.springframework.web.bind.annotation.ResponseBody; | |
| @SpringBootApplication | |
| @Controller | |
| public class Demo2Application { | |
| public static void main(String[] args) { | |
| SpringApplication.run(Demo2Application.class, args); | |
| } | |
| @GetMapping("/") | |
| @ResponseBody | |
| @ThrowOrekyuu | |
| public String hello() { | |
| return "hello"; | |
| } | |
| } |
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.example; | |
| public class Orekyuu extends Throwable { | |
| } |
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.example; | |
| import java.lang.annotation.*; | |
| @Target(ElementType.METHOD) | |
| @Retention(RetentionPolicy.RUNTIME) | |
| @Documented | |
| public @interface ThrowOrekyuu { | |
| } |
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.example; | |
| import org.aspectj.lang.ProceedingJoinPoint; | |
| import org.aspectj.lang.annotation.Around; | |
| import org.aspectj.lang.annotation.Aspect; | |
| import org.springframework.stereotype.Component; | |
| @Aspect | |
| @Component | |
| public class ThrowOrekyuuAspect { | |
| @Around("@annotation(com.example.ThrowOrekyuu)") | |
| public Object projectAuthAspect(ProceedingJoinPoint joinPoint) throws Throwable { | |
| throw new Orekyuu(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment