1 2 package SOFA.Util; 3 4 import java.io.File ; 5 import java.io.FileInputStream ; 6 7 11 public class ConnGenPathInfo { 12 13 public static class CPException extends RuntimeException { 14 public CPException() { super(); } 15 public CPException(String m) { super(m); } 16 public CPException(String m, Throwable cause) { super(m, cause); } 17 } 18 19 public static java.util.Properties trIndex; 20 public static String 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 (); 28 try { 29 FileInputStream fis = new FileInputStream (trDir+File.separator+"iface"+File.separator+"index"); 30 trIndex.load(fis); 31 fis.close(); 32 } catch (java.io.IOException e) { 33 throw new CPException("IOException: "+e.getMessage()); 34 } 35 } 36 37 42 public static String getConnGenClassPath(String iface) throws CPException { 43 StringBuffer classpath = new StringBuffer (); 44 45 java.util.StringTokenizer st=new java.util.StringTokenizer (iface,","); 46 while (st.hasMoreTokens()) { 47 String token=st.nextToken().trim(); 48 String subdir = (String ) 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 getRMICOutDir() { 63 return trDir+File.separator+"congen"; 64 } 65 66 public static String getIDLOutDir() { 67 return trDir+File.separator+"congen"; 68 } 69 } 70 | Popular Tags |