|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 必須 | オプション | 詳細: 要素 | |||||||||
@Target(value={TYPE,ANNOTATION_TYPE})
@Retention(value=RUNTIME)
public @interface AnnotateWithDaoインタフェースの実装クラスのソースコードにアノテーションを注釈することを示します。
このアノテーションには2種類の使い方があります
AnnotateWith
を注釈し、そのアノテーションをDaoインタフェースに注釈する。
このアノテーションを直接的であれ間接的であれDaoインタフェースに注釈する場合、Dao.config() に値を設定してはいけません。
@Dao
@AnnotateWith(annotations = {
@Annotation(target = AnnotationTarget.CONSTRUCTOR, type = Inject.class),
@Annotation(target = AnnotationTarget.CONSTRUCTOR_PARAMETER, type = Named.class, elements = "\"sales\"") })
public interface EmployeeDao {
...
}
実装クラスは次のようになります。
public class EmployeeDaoImpl extends org.seasar.doma.internal.jdbc.dao.AbstractDao implements example.EmployeeDao {
@com.google.inject.Inject()
public EmployeeDaoImpl(@com.google.inject.name.Named("sales") org.seasar.doma.jdbc.Config config) {
super(new org.seasar.doma.jdbc.ConfigProxy(config));
}
...
}
AnnotateWith を任意のアノテーションに注釈し、そのアノテーションをDaoに注釈することも可能です。 たとえば、ここでは、
GuiceConfig というアノテーションに AnnotateWith を注釈する例を示します。
@AnnotateWith(annotations = {
@Annotation(target = AnnotationTarget.CONSTRUCTOR, type = Inject.class),
@Annotation(target = AnnotationTarget.CONSTRUCTOR_PARAMETER, type = Named.class, elements = "\"sales\"") })
public @interface GuiceConfig {
...
}
GuiceConfig をDaoに注釈すれば、AnnotateWithを直接注釈した場合と同様の実装クラスが生成されます。
@Dao
@GuiceConfig
public interface EmployeeDao {
...
}
| 必須要素の概要 | |
|---|---|
Annotation[] |
annotations
アノテーション |
| 要素の詳細 |
|---|
public abstract Annotation[] annotations
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 必須 | オプション | 詳細: 要素 | |||||||||