KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Connector > EEG > EEM > Actions > IDLIface


1 /*
2  * IDLIface.java
3  *
4  * Created on 2. duben 2002, 23:37
5  */

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 /**
13  *
14  * @author ghort
15  * @version
16  */

17 public class IDLIface implements ActionInterface {
18
19     /** Creates new IDLIface */
20    public IDLIface(java.util.HashMap JavaDoc props) {
21    }
22
23     public String JavaDoc getName() {
24         return "idliface";
25     }
26      
27     public void perform(SOFA.Connector.Property[] params, String JavaDoc sourceDir, String JavaDoc sourcePackage, String JavaDoc destDir, String JavaDoc destPackage) throws ActionException {
28         String JavaDoc 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 JavaDoc dirClass=Class.forName(sourcePackage+"."+generator);
56
57             Class JavaDoc[] coParCls=new Class JavaDoc[2];
58             coParCls[0]=Class.forName("java.lang.String");
59             coParCls[1]=Class.forName("[LSOFA.Connector.Property;");
60             java.lang.reflect.Constructor JavaDoc dirClassCo=dirClass.getConstructor(coParCls);
61
62             Object JavaDoc[] coPar=new Object JavaDoc[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 JavaDoc e) {
70             throw new ActionException("Can't generate java source "+destDir+"/"+outFile+".",e);
71         }
72     }
73      
74 }
75
Popular Tags