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.AfterReturningAdvice;
    21  
    22  /**
    23   * {@code AbstractAfterReturningAdvice} provides implementations of methods needed by
    24   * {@link AfterReturningAdvice} implementations.
    25   * 
    26   * @author Simon Wacker
    27   */
    28  class org.as2lib.aop.advice.AbstractAfterReturningAdvice extends AbstractAdvice {
    29  	
    30  	/**
    31  	 * Constructs a new {@code AbstractAfterReturningAdvice} instance.
    32  	 * 
    33  	 * @param aspect (optional) the aspect that contains this advice
    34  	 */
    35  	private function AbstractAfterReturningAdvice(aspect:Aspect) {
    36  		super(aspect);
    37  	}
    38  	
    39  	/**
    40  	 * Proceeds the passed-in {@code joinPoint} with the given {@code args} and returns
    41  	 * the result of this procession after invoking this advice's {@code execute}
    42  	 * method passing the given {@code joinPoint} and the result if the procession
    43  	 * returned successfully and did not result in an exception.
    44  	 * 
    45  	 * @param joinPoint the reached join point
    46  	 * @param args the arguments to use for the procession of the join point, these are
    47  	 * normally the ones that were originally passed-to the join point
    48  	 * @return the result of the procession of the given {@code joinPoint} with the
    49  	 * given {@code args}
    50  	 * @throws * if the procession of the {@code joinPoint} with the given {@code args}
    51  	 * results in an exception or if this advice's {@code execute} method threw an
    52  	 * exception
    53  	 */
    54  	private function executeJoinPoint(joinPoint:JoinPoint, args:Array) {
    55  		var result = joinPoint.proceed(args);
    56  		AfterReturningAdvice(this).execute(joinPoint, result);
    57  		return result;
    58  	}
    59  	
    60  }