1 package org.jicengine.operation; 2 3 4 13 public class FactoryInvocationOperation implements Operation { 14 15 private String factoryName; 16 private Operation[] parameters; 17 18 23 public FactoryInvocationOperation(String name, Operation[] parameters) 24 { 25 this.factoryName = name; 26 this.parameters = parameters; 27 } 28 29 public boolean needsParameters() 30 { 31 return this.parameters.length > 0; 32 } 33 34 public boolean needsParameter(String name) 35 { 36 for (int i = 0; i < this.parameters.length; i++) { 37 if( this.parameters[i].needsParameter(name) ){ 38 return true; 39 } 40 } 41 return false; 42 } 43 44 public Object execute(Context context) throws OperationException 45 { 46 Factory factory = (Factory) context.getObject(this.factoryName); 47 48 Object [] arguments = MethodInvocationOperation.evaluateParameters(this.parameters,context); 49 50 Object result = factory.invoke(arguments); 51 52 return result; 53 } 54 } 55 56 | Popular Tags |