この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:3
ページ更新者:guest
更新日時:2018-05-10 05:44:58

タイトル: @After

本稿はSpringFrameworkの@Afterについて説明します。

@Afterとは

@Afterはメソッド単位で付与するアノテーションです。

@Afterは@Acpectが付与されたクラス内で使用されます。

@Afterが付与されたクラスは、execution内の条件に当てはまる場合、対象の処理の実行後に@Afterメソッドが実行されます。

※AOPに関してはこちらを参照。

以下、@Afterを使用したサンプルです。

@Aspect
@Component
public class TestAOP {

    @Before("execution(* com.example.springmvc2.*.*(..))")
    public void before(JoinPoint joinPoint) {
        System.out.println("Method Start:"  + joinPoint.getSignature());
    }

    @After("execution(* com.example.springmvc2.*.*(..))")
    public void after(JoinPoint joinPoint) {
        System.out.println("Method End:"  + joinPoint.getSignature());
    }
}