스프링 스케줄러를 이용하여 콘텐츠 예약 오픈 설정
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package kr.co.vividnext.sodalive.common.annotation
|
||||
|
||||
import org.aspectj.lang.annotation.Aspect
|
||||
import org.aspectj.lang.annotation.Before
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class SchedulerOnly
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
class SchedulerOnlyAspect {
|
||||
|
||||
@Before("@annotation(SchedulerOnly)")
|
||||
fun checkSchedulerAccess() {
|
||||
if (!isSchedulerThread()) {
|
||||
throw IllegalStateException("잘못된 접근입니다.")
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSchedulerThread(): Boolean {
|
||||
// 스케줄러 스레드 여부를 판단하는 간단한 로직
|
||||
return Thread.currentThread().name.contains("scheduler")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user