1 20 package org.objectweb.modfact.qvt.engine; 21 22 import javax.jmi.reflect.*; 23 24 import java.util.*; 25 26 public class EntryPointApplyer { 27 28 RefPackage src, target, rulesPkg; 29 Hashtable bindingTable = new Hashtable(); 30 RefObject rulesUnit; 31 32 public EntryPointApplyer(RefPackage rulesPkg, RefPackage src, RefPackage target) throws Exception { 33 this.src = src; 34 this.target = target; 35 this.rulesPkg = rulesPkg; 36 init(); 37 } 38 39 public void applyAllUnits() throws Exception { 40 Iterator it = rulesPkg.refClass("RulesUnit").refAllOfClass().iterator(); 41 while(it.hasNext()) { 42 RefObject rulesUnit = (RefObject) it.next(); 43 applyEntryPoints(rulesUnit); 44 } 45 } 46 47 public void applyEntryPoints(RefObject rulesUnit) throws Exception { 48 49 RefObject[] rules; 50 rules = (RefObject[]) ( (Collection) rulesUnit.refGetValue("rules") 51 ).toArray(new RefObject[0]); 52 53 for(int i=0; i<rules.length; i++) { 54 if( Reflection.isOfType(rules[i],"EntryPointRule") ) { 55 applyEntryPoint( rules[i]); 56 } 57 } 58 } 59 60 void applyEntryPoint(RefObject entryPointRule) throws Exception { 61 Object [] contexts = Reflection.allOfType( 63 src ,(String )entryPointRule.refGetValue("context") 64 ).toArray(); 65 for(int i=0; i<contexts.length ; i++) { 67 Hashtable args = new Hashtable(); 68 args.put("context", contexts[i]); 69 (new RuleBinding( bindingTable 70 ,entryPointRule, src, target, args, 0)).execute(); 71 } 72 } 73 74 void init() { 75 String verbose = System.getProperty("fr.lip6.modfact.qvt.engine.verbose"); 76 if("true".equals(verbose)) { 77 RuleBinding.verbose = true; 78 } 79 } 80 } 81 82 | Popular Tags |