001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.aop.aspectj;
018
019import java.io.Serializable;
020import java.lang.reflect.Method;
021
022import org.aopalliance.intercept.MethodInterceptor;
023import org.aopalliance.intercept.MethodInvocation;
024
025import org.springframework.aop.AfterAdvice;
026
027/**
028 * Spring AOP advice wrapping an AspectJ after advice method.
029 *
030 * @author Rod Johnson
031 * @since 2.0
032 */
033@SuppressWarnings("serial")
034public class AspectJAfterAdvice extends AbstractAspectJAdvice
035                implements MethodInterceptor, AfterAdvice, Serializable {
036
037        public AspectJAfterAdvice(
038                        Method aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
039
040                super(aspectJBeforeAdviceMethod, pointcut, aif);
041        }
042
043
044        @Override
045        public Object invoke(MethodInvocation mi) throws Throwable {
046                try {
047                        return mi.proceed();
048                }
049                finally {
050                        invokeAdviceMethod(getJoinPointMatch(), null, null);
051                }
052        }
053
054        @Override
055        public boolean isBeforeAdvice() {
056                return false;
057        }
058
059        @Override
060        public boolean isAfterAdvice() {
061                return true;
062        }
063
064}