KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > Util > ConnGenPathInfo


1 /* $Id: ConnGenPathInfo.java,v 1.2 2004/05/20 14:23:53 bures Exp $ */
2 package SOFA.Util;
3
4 import java.io.File JavaDoc;
5 import java.io.FileInputStream JavaDoc;
6
7 /** Provides path information for connector generator.
8   *
9   * @author Petr Hnetynka
10   */

11 public class ConnGenPathInfo {
12
13   public static class CPException extends RuntimeException JavaDoc {
14     public CPException() { super(); }
15     public CPException(String JavaDoc m) { super(m); }
16     public CPException(String JavaDoc m, Throwable JavaDoc cause) { super(m, cause); }
17   }
18
19   public static java.util.Properties JavaDoc trIndex;
20   public static String JavaDoc trDir;
21
22   static {
23     trDir = System.getProperty("sofa.tr.dir", null);
24     if (trDir == null) {
25       throw new CPException("Specify TR directrory (java property \"sofa.tr.dir\")");
26     }
27     trIndex = new java.util.Properties JavaDoc();
28     try {
29       FileInputStream JavaDoc fis = new FileInputStream JavaDoc(trDir+File.separator+"iface"+File.separator+"index");
30       trIndex.load(fis);
31       fis.close();
32     } catch (java.io.IOException JavaDoc e) {
33       throw new CPException("IOException: "+e.getMessage());
34     }
35   }
36   
37   /** Returns classpath for javac action of connector generator.
38     *
39     * @param iface user interface of generated connector (more interfaces can be delimited by comma, e.g. "package.interface1,package.interface2")
40     * @return classpath
41     */

42   public static String JavaDoc getConnGenClassPath(String JavaDoc iface) throws CPException {
43     StringBuffer JavaDoc classpath = new StringBuffer JavaDoc();
44     
45     java.util.StringTokenizer JavaDoc st=new java.util.StringTokenizer JavaDoc(iface,",");
46     while (st.hasMoreTokens()) {
47       String JavaDoc token=st.nextToken().trim();
48       String JavaDoc subdir = (String JavaDoc) trIndex.get(token);
49       if (subdir == null) {
50         throw new CPException("No such interface in TR: '"+token+"'");
51       }
52       classpath.append(trDir+File.separator+"iface"+File.separator+subdir);
53       classpath.append(File.pathSeparator);
54     }
55     
56     classpath.append(trDir+File.separator+"congen");
57     classpath.append(File.pathSeparator);
58     classpath.append(System.getProperty("java.class.path"));
59     return classpath.toString();
60   }
61
62   public static String JavaDoc getRMICOutDir() {
63     return trDir+File.separator+"congen";
64   }
65
66   public static String JavaDoc getIDLOutDir() {
67     return trDir+File.separator+"congen";
68   }
69 }
70
Popular Tags