2
私は問題があり、誰かが私を助けてくれることを願っています。Spring - AOP - 注釈コードの生成
私は、ドメインエンティティ持っている私はSpringフレームワークを使用して、私は自分のドメインクラスの1内部メソッドを生成したい...:
@Entity
class AbcDomain {
private int id;
@CustomAnnotation(p1="x1", p2="y1")
private String a;
@CustomAnnotation(p1="x2", p2="y2")
private String b;
@CustomAnnotation(p1="3", p2="y3")
private int c;
private Set<Integer> d;
... getters and setters
}
をそして私は「作成したいですm "メソッドをこのドメインに追加します。 方法は、このような「CustomAnnotation」注釈ましfileds、含まれています。私は解決策を見つけることができる場所
@Entity
class AbcDomain {
... Prev code ...
public String m() {
if ("x1".equals(a)) // "x1" comes from the annotation's p1 param
return "y1"; // "y1" comes from the annotation's p2 param
if ("x2".equals(b)) // "x2" comes from the annotation's p1 param
return "y2"; // "y2" comes from the annotation's p2 param
if (c == 3) // 3 comes from the annotation's p1 param
return "y3"; // "y3" comes from the annotation's p1 param
}
}
私は春とAOPに非常に新しいです、誰も私を助けることができますか?
おかげ