1 6 7 package SOFA.Connector.EEG.EEM.Actions; 8 9 import SOFA.Connector.EEG.EEM.ActionException; 10 import SOFA.Connector.EEG.EEM.ActionInterface; 11 12 17 public class IDLIface implements ActionInterface { 18 19 20 public IDLIface(java.util.HashMap props) { 21 } 22 23 public String getName() { 24 return "idliface"; 25 } 26 27 public void perform(SOFA.Connector.Property[] params, String sourceDir, String sourcePackage, String destDir, String destPackage) throws ActionException { 28 String outFile, interfaceName, ifaceCDL, generator; 29 if ((outFile=SOFA.Connector.Property.findFirst(params,"file"))==null) { 30 throw new ActionException("file param not specified"); 31 } 32 if ((interfaceName=SOFA.Connector.Property.findFirst(params,"interface"))==null) { 33 throw new ActionException("class param not specified"); 34 } 35 if ((generator=SOFA.Connector.Property.findFirst(params,"generator"))==null) { 36 throw new ActionException("generator param not specified"); 37 } 38 if ((ifaceCDL=SOFA.Connector.Property.findFirst(params,"ifaceCDL"))==null) { 39 throw new ActionException("ifaceCDL param not specified"); 40 } 41 42 try { 43 SOFA.Connector.EEG.CodeWriter.IDLWriter idlwriter=new SOFA.Connector.EEG.CodeWriter.IDLWriter(ifaceCDL); 44 idlwriter.setOut(destDir+"/"+outFile,destPackage,interfaceName); 45 46 SOFA.Connector.Property[] dirParams=new SOFA.Connector.Property[params.length+3]; 47 dirParams[0]=new SOFA.Connector.Property("outFile",destDir+"/"+outFile); 48 dirParams[1]=new SOFA.Connector.Property("outInterface",interfaceName); 49 dirParams[2]=new SOFA.Connector.Property("outPackage",destPackage); 50 51 for (int i=0;i<params.length;i++) { 52 dirParams[i+3]=params[i]; 53 } 54 55 Class dirClass=Class.forName(sourcePackage+"."+generator); 56 57 Class [] coParCls=new Class [2]; 58 coParCls[0]=Class.forName("java.lang.String"); 59 coParCls[1]=Class.forName("[LSOFA.Connector.Property;"); 60 java.lang.reflect.Constructor dirClassCo=dirClass.getConstructor(coParCls); 61 62 Object [] coPar=new Object [2]; 63 coPar[0]=ifaceCDL; 64 coPar[1]=dirParams; 65 SOFA.Connector.EEG.CodeWriter.IDLWriterDirector director=(SOFA.Connector.EEG.CodeWriter.IDLWriterDirector)dirClassCo.newInstance(coPar); 66 67 idlwriter.write(director); 68 69 } catch (Exception e) { 70 throw new ActionException("Can't generate java source "+destDir+"/"+outFile+".",e); 71 } 72 } 73 74 } 75 | Popular Tags |