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.except.IllegalArgumentException; 18 import org.as2lib.aop.joinpoint.AbstractJoinPoint; 19 import org.as2lib.env.except.UnsupportedOperationException; 20 import org.as2lib.env.reflect.PropertyInfo; 21 import org.as2lib.env.reflect.TypeMemberInfo; 22 import org.as2lib.aop.JoinPoint; 23 24 /** 25 * {@code PropertyJoinPoint} represents any type of access to a property, be it set or 26 * get access. 27 * 28 * @author Simon Wacker 29 */ 30 class org.as2lib.aop.joinpoint.PropertyJoinPoint extends AbstractJoinPoint implements JoinPoint { 31 32 /** The info representing the property. */ 33 private var info:PropertyInfo; 34 35 /** 36 * Constructs a new {@code PropertyJoinPoint} instance. 37 * 38 * @param info the property info of the represented property 39 * @param thiz the logical this of the interception 40 * @throws IllegalArgumentException if argument {@code info} is {@code null} or 41 * {@code undefined} 42 * @see <a href="http://www.simonwacker.com/blog/archives/000068.php">Passing Context</a> 43 */ 44 public function PropertyJoinPoint(info:PropertyInfo, thiz) { 45 super(thiz); 46 if (!info) throw new IllegalArgumentException("Argument 'info' must not be 'null' nor 'undefined'.", this, arguments); 47 this.info = info; 48 } 49 50 /** 51 * Returns the info of the represented property. This is a {@link PropertyInfo} 52 * instance. 53 * 54 * @return the info of the represented property 55 */ 56 public function getInfo(Void):TypeMemberInfo { 57 return info; 58 } 59 60 /** 61 * Throws an unsupported operation exception because this method is not supported 62 * by an unspecified property access. Use the {@link GetPropertyJoinPoint} or 63 * {@link SetPropertyJoinPoint} classes if you want to be able to proceed a property 64 * join point. 65 * 66 * @param args the arguments to use for the procession 67 * @return the result of the procession 68 * @throws UnsupportedOperationException 69 */ 70 public function proceed(args:Array) { 71 throw new UnsupportedOperationException("The execute operation is not supported by PropertyJoinPoint instances [" + this + "].", this, arguments); 72 } 73 74 /** 75 * Returns this join point's type. 76 * 77 * @return {@link AbstractJoinPoint#getType} 78 */ 79 public function getType(Void):Number { 80 return PROPERTY; 81 } 82 83 /** 84 * Returns a copy of this join point with an updated logical this. This join point 85 * is left unchanged. 86 * 87 * @param thiz the new logical this 88 * @return a copy of this join point with an updated logical this 89 * @see #getThis 90 */ 91 public function update(thiz):JoinPoint { 92 return new PropertyJoinPoint(this.info, thiz); 93 } 94 95 /** 96 * Returns a copy of this join point that reflects its current state. 97 * 98 * <p>It is common practice to create a new join point for a not-fixed method info. 99 * This is when the underlying concrete method this join point reflects may change. 100 * To make the concrete method and other parts that may change fixed you can use 101 * this method to get a new fixed join point, a snapshot. 102 * 103 * @return a snapshot of this join point 104 */ 105 public function snapshot(Void):JoinPoint { 106 return new PropertyJoinPoint(this.info.snapshot(), getThis()); 107 } 108 109 }