KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > aop > aspectj > AspectJAfterAdvice


1 /*
2  * Copyright 2002-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.aop.aspectj;
18
19 import java.lang.reflect.Method JavaDoc;
20
21 import org.aopalliance.intercept.MethodInterceptor;
22 import org.aopalliance.intercept.MethodInvocation;
23
24 import org.springframework.aop.AfterAdvice;
25
26 /**
27  * Spring AOP advice wrapping an AspectJ after advice method.
28  *
29  * @author Rod Johnson
30  * @since 2.0
31  */

32 public class AspectJAfterAdvice extends AbstractAspectJAdvice implements MethodInterceptor, AfterAdvice {
33
34     public AspectJAfterAdvice(
35             Method JavaDoc aspectJBeforeAdviceMethod, AspectJExpressionPointcut pointcut, AspectInstanceFactory aif) {
36
37         super(aspectJBeforeAdviceMethod, pointcut, aif);
38     }
39     
40     public Object JavaDoc invoke(MethodInvocation mi) throws Throwable JavaDoc {
41         try {
42             return mi.proceed();
43         }
44         finally {
45             invokeAdviceMethod(getJoinPointMatch(), null, null);
46         }
47     }
48
49     public boolean isBeforeAdvice() {
50         return false;
51     }
52
53     public boolean isAfterAdvice() {
54         return true;
55     }
56
57 }
58
Popular Tags