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.util.ClassUtil; 18 import org.as2lib.app.exec.Call; 19 20 /** 21 * Constructor Call is to call a constructor by remote. 22 * It default application is within Testcases where you try if a constructor throws a exception. 23 * 24 * @author Martin Heidegger 25 * @author Christoph Atteneder 26 */ 27 class org.as2lib.app.exec.ConstructorCall extends Call { 28 29 /** The Class to be instanciated. */ 30 private var clazz:Function; 31 32 /** 33 * Constructs a new Call instance. 34 * 35 * @param clazz Class to be constructed. 36 */ 37 public function ConstructorCall(clazz:Function) { 38 super (this, clazz); 39 this.clazz = clazz; 40 } 41 42 /** 43 * Executes the passed method on the passed object with the given 44 * arguments and returns the result of the execution. 45 * 46 * @param args the arguments that shall be passed 47 * @return the result of the method execution 48 */ 49 public function execute() { 50 var instance = ClassUtil.createCleanInstance(clazz); 51 return clazz.apply(instance, arguments); 52 } 53 54 }