これは問題のコードです。トランザクションアノテーションでヒットするAspectJ Pointcutを取得し、変数を取り込もうとしています
@Aspect
@EnableAspectJAutoProxy
public class TransactionAspect extends TransactionSynchronizationAdapter {
public TransactionMonitor transactionMonitor;
String message;
@Before("execution(@org.springframework.transaction.annotation.Transactional * *.*(..)) && args(message,..))")
public void registerTransactionSynchronization(String message) {
TransactionSynchronizationManager.registerSynchronization(this);
this.message = message;
}
public void setTransactionMonitor(TransactionMonitor transactionMonitor) {
this.transactionMonitor = transactionMonitor;
}
私はSpringのコンフィグレーションファイルでこのAspect Beanを作成しました。
私はもともとこれは働いていた@Beforeブロック @Before( "@注釈(org.springframework.transaction.annotation.Transactional)")に
これを持っていました。私がTransactionalアノテーションを持つ場所は、このPointcutを呼び出します。しかし、私はまた、私はこの側面を置く方法から変数が必要です。それはargs(メッセージ)が入ってくる場所です。私はそのメッセージ(Stringです)を取得するいくつかの異なる方法を試しましたが、役に立たないです。
このPointcutをTransactional Annotationでヒットさせる方法と、Transactionalで注釈を付けたメソッドから変数をプルする方法を知っている人はいますか?親切にありがとう。
これは完全に機能しました。ありがとう! –