[翻訳]Guice User's Guide ■23. Creating Scope Annotations
スコープアノテーションの作り方
Annotations used for scoping should:
範囲指定のために使うアノテーションは以下のように作成します。
- Have a @Rentention(RUNTIME) annotation so we can see the annotation at runtime.
- Have a @Target({TYPE}) annotation. Scope annotations only apply to implementation classes..
- Have a @ScopeAnnotation meta-annotation. Only one such annotation can apply to a given class.
- 実行時に、アノテーションを参照できるように@Rentention(RUNTIME)アノテーションを記述してください。
- @Target({TYPE})アノテーションを記述してください。スコープアノテーションは、実装クラスにのみ指定可能です。
- @ScopeAnnotationというメタアノテーションを記述してください。そのアノテーションは与えられるただ1つのクラスにのみ利用可能です。
For example:
たとえば以下です。
/**
* Scopes bindings to the current transaction.
*/
@Retention(RUNTIME)
@Target({TYPE})
@ScopeAnnotation
public @interface TransactionScoped {}