1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (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.mozilla.org/MPL/MPL-1.1.html 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 import org.as2lib.aop.Aspect; 18 import org.as2lib.aop.JoinPoint; 19 import org.as2lib.aop.advice.AbstractAdvice; 20 import org.as2lib.aop.advice.AfterAdvice; 21 22 /** 23 * {@code AbstractAfterAdvice} provides implementations of methods needed by 24 * {@link AfterAdvice} implementations. 25 * 26 * @author Simon Wacker 27 * @see <a href="http://www.simonwacker.com/blog/archives/000066.php">Advice</a> 28 */ 29 class org.as2lib.aop.advice.AbstractAfterAdvice extends AbstractAdvice { 30 31 /** 32 * Constructs a new {@code AbstractAfterAdvice} instance. 33 * 34 * @param aspect (optional) the aspect that contains this advice 35 */ 36 private function AbstractAfterAdvice(aspect:Aspect) { 37 super(aspect); 38 } 39 40 /** 41 * Proceeds the passed-in {@code joinPoint} with the given {@code args} and returns 42 * the result of this procession after invoking this advice's {@code execute} 43 * method passing the given {@code joinPoint}. This {@code execute} method is 44 * always invoked, no matter whether the procession of the {@code joinPoint} 45 * results in an exception of not. 46 * 47 * @param joinPoint the reached join point 48 * @param args the arguments to use for the procession of the join point, these are 49 * normally the ones that were originally passed-to the join point 50 * @return the result of the procession of the given {@code joinPoint} with the 51 * given {@code args} 52 * @throws * if the procession of the {@code joinPoint} with the given {@code args} 53 * results in an exception or if this advice's {@code execute} method threw an 54 * exception 55 */ 56 private function executeJoinPoint(joinPoint:JoinPoint, args:Array) { 57 var result; 58 try { 59 result = joinPoint.proceed(args); 60 } finally { 61 AfterAdvice(this).execute(joinPoint); 62 } 63 return result; 64 } 65 66 }