분류 전체보기(4)
-
Spring Boot의 EventHandler #2
이전 글 > 2021/02/02 - [분류 전체보기] - Spring Boot의 EventHandler #1 Spring Boot의 EventHandler #1 Spring Framework를 기반으로 애플리케이션을 구성할 때, 보통 웹 기반으로 합니다. @Controller나 @RestController annotation을 사용하여 외부의 이벤트(Http Request)에 의해서 동작합니다. 때로는 외부 요청.. matriluna.tistory.com 이전 글에서는 Spring에서 제공하는 ApplicationStartedEvent를 이용하여 애플리케이션이 실행된 직후에 원하는 동작을 수행하였습니다. 개발자가 자신이 만든 이벤트를 발행해 보도록 하겠습니다. 1. 개발자가 작성한 Event 발행 먼저 ..
2021.02.07 -
Spring Boot의 EventHandler #1
Spring Framework를 기반으로 애플리케이션을 구성할 때, 보통 웹 기반으로 합니다. @Controller나 @RestController annotation을 사용하여 외부의 이벤트(Http Request)에 의해서 동작합니다. 때로는 외부 요청 없이 Spring Application이 구동될 때, 어떤 작업을 처리하고 싶을 때가 있습니다. 가장 쉬운 방법은 Spring Bean의 생성자에 원하는 코드를 작성하는 것입니다. 1. 생성자를 이용한 초기화 생성자를 이용한 초기화 @Component class DemoComponent { private final Logger log = LoggerFactory.getLogger(this.getClass()); DemoComponent() { log.i..
2021.02.02 -
Spring Boot 2.4.X에서 RestController의 JSON 응답
@RestController annotation을 이용해서 API를 만든다고 생각해 봅시다. 클라이언트의 요청과 응답을 처리하기 위해서 다음과 같은 클래스를 구성하였습니다. public class TestClass { private final String value; private final String key; public TestClass(String value) { this.value = value; this.key = null; } } 일단 @RestController를 사용해서 하나의 Controller를 생성하여 어떤 결과가 나오는지 확인해 보겠습니다. @RestController @RequestMapping("/test") class TestController { @GetMapping pub..
2021.02.01 -
Spring AOP 적용 규칙
@Around("@annotation(inc.sdt.messaging.annotation.Publishable)") public Object doAfter(ProceedingJoinPoint joinPoint) throws Throwable { ... } @Aspect Annotation을 이용하여 Annotation Processor를 개발하는 도중에 아래와 같은 문제가 발생했습니다. Business Logic public IotHubMessageResult execute(Message message, Object o) { final String receivedMessage = new String(message.getBytes(), Message.DEFAULT_IOTHUB_MESSAGE_CHARSET)..
2021.02.01