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.env.reflect.ConstructorInfo; 18 import org.as2lib.aop.joinpoint.MethodJoinPoint; 19 import org.as2lib.aop.JoinPoint; 20 21 /** 22 * {@code ConstructorJoinPoint} represents a constructor as join point. 23 * 24 * @author Simon Wacker 25 */ 26 class org.as2lib.aop.joinpoint.ConstructorJoinPoint extends MethodJoinPoint { 27 28 /** 29 * Constructs a new {@code ConstructorJoinPoint} instance. 30 * 31 * @param info the info of the represented constructor 32 * @param thiz the logical this of the interception 33 * @throws IllegalArgumentException if argument {@code info} is {@code null} or 34 * {@code undefined} 35 * @see <a href="http://www.simonwacker.com/blog/archives/000068.php">Passing Context</a> 36 */ 37 public function ConstructorJoinPoint(info:ConstructorInfo, thiz) { 38 super(info, thiz); 39 } 40 41 /** 42 * Returns the type of this join point. 43 * 44 * @return {@link AbstractJoinPoint#CONSTRUCTOR} 45 */ 46 public function getType(Void):Number { 47 return CONSTRUCTOR; 48 } 49 50 /** 51 * Returns a copy of this join point with an updated logical this. This join point 52 * is left unchanged. 53 * 54 * @param thiz the new logical this 55 * @return a copy of this join point with an updated logical this 56 * @see #getThis 57 */ 58 public function update(thiz):JoinPoint { 59 return new ConstructorJoinPoint(ConstructorInfo(this.info), thiz); 60 } 61 62 /** 63 * Returns a copy of this join point that reflects its current state. 64 * 65 * <p>It is common practice to create a new join point for a not-fixed constructor 66 * info. This is when the underlying concrete constructor this join point reflects 67 * may change. To make the concrete constructor and other parts that may change 68 * fixed you can use this method to get a new fixed join point, a snapshot. 69 * 70 * @return a snapshot of this join point 71 */ 72 public function snapshot(Void):JoinPoint { 73 return new ConstructorJoinPoint(ConstructorInfo(this.info.snapshot()), getThis()); 74 } 75 76 }