Home Java의 Annotation 알아보기 - @Indexed
Post
Cancel

Java의 Annotation 알아보기 - @Indexed

출처: Package org.springframework.core.annotation / Annotation Interface AliasFor


@Configuration

1
2
3
4
5
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Indexed {
}
Indicate that the annotated element represents a stereotype for the index.

</div>

    이 애너테이션이 붙은 요소는 해당 인덱스에 대하여 스테레오타입stereotype임을 나타낸다.

(생략)

메타 애너테이션인 이 @Indexed
붙어있기도 한 기본 애너테이션인 @Component
생각해보자.
어떤 컴포넌트에 @Component가 붙어있다면,
이 컴포넌트에 대한 공간은
org.springframework.stereotype.Component라는
스테레오타입을 사용하는
인덱스에 추가될 것이다.

이 애너테이션은
메타 애너테이션이기도 하다.
그래서 다음과 같이
커스텀 애너테이션을 만들 수도 있다.

1
2
3
4
5
6
7
8
package com.example;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
@Service
public @interface PrivilegedService { ... }

위의 애너테이션에서는
타입(TYPE)으로 나타나고 있는데,
이 경우에는 두 개의 스테레오타입이
인덱스에 추가된다.
즉, org.springframework.stereotype.Component
com.example.PrivilegedService이다.

@Service에는 @Indexed
직접적으로 붙어있지는 않지만,
@Component를 통하여
메타 애너테이션이 붙어있다.

Contents