Skip to content

Instantly share code, notes, and snippets.

@orekyuu
Created November 5, 2016 11:56
Show Gist options
  • Save orekyuu/74c0009e3010041c13818753aec0e435 to your computer and use it in GitHub Desktop.
Save orekyuu/74c0009e3010041c13818753aec0e435 to your computer and use it in GitHub Desktop.
throw_orekyuu
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";
}
}
package com.example;
public class Orekyuu extends Throwable {
}
package com.example;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ThrowOrekyuu {
}
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