1 2 package SOFA.SOFAnode.Run; 3 import java.io.File ; 4 import java.io.FileInputStream ; 5 6 import javax.xml.parsers.DocumentBuilder ; 7 import javax.xml.parsers.DocumentBuilderFactory ; 8 9 import org.w3c.dom.Document ; 10 11 15 public class TRAccess { 16 17 28 public static SOFA.SOFAnode.Run.Deployment.DeploymentDescriptor getDeplDescr(String applname, String ddname) throws java.net.MalformedURLException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { 29 String trString = System.getProperty("sofa.tr.url","file:/sofa/tr/"); 30 String path = trString+"impl"; 31 path = path + fullNameToURLName(applname, ddname); 32 java.net.URL url = new java.net.URL (path); 33 java.net.URLConnection con = url.openConnection(); 34 java.io.InputStream is = con.getInputStream(); 35 SOFA.SOFAnode.Run.Deployment.DeploymentDescriptor dd = new SOFA.SOFAnode.Run.Deployment.DeploymentDescriptorImpl(is); 36 is.close(); 37 return dd; 38 } 39 40 50 public static SOFA.SOFAnode.Run.Deployment.DeploymentDescriptor getDeplDescrLocal(String applname, String ddname) throws java.net.MalformedURLException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { 51 String trString = System.getProperty("sofa.tr.dir","/sofa/tr"); 52 String path = trString+File.separator+"impl"; 53 path = path + fullNameToURLName(applname, ddname); 54 java.io.FileInputStream is = new FileInputStream (path); 55 SOFA.SOFAnode.Run.Deployment.DeploymentDescriptor dd = new SOFA.SOFAnode.Run.Deployment.DeploymentDescriptorImpl(is); 56 is.close(); 57 return dd; 58 } 59 60 71 public static Document getDeplDescrXML(String applname, String ddname) throws java.net.MalformedURLException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { 72 String trString = System.getProperty("sofa.tr.url","file:/sofa/tr/"); 73 String path = trString+"impl"; 74 path = path + fullNameToURLName(applname, ddname); 75 java.net.URL url = new java.net.URL (path); 76 java.net.URLConnection con = url.openConnection(); 77 java.io.InputStream is = con.getInputStream(); 78 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 79 DocumentBuilder builder = factory.newDocumentBuilder(); 80 Document document = builder.parse(is); 81 is.close(); 82 return document; 83 } 84 85 95 public static Document getDeplDescrXMLLocal(String applname, String ddname) throws java.net.MalformedURLException , java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { 96 String trString = System.getProperty("sofa.tr.dir","/sofa/tr"); 97 String path = trString+File.separator+"impl"; 98 path = path + fullNameToURLName(applname, ddname); 99 java.io.FileInputStream is = new FileInputStream (path); 100 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 101 DocumentBuilder builder = factory.newDocumentBuilder(); 102 Document document = builder.parse(is); 103 is.close(); 104 return document; 105 } 106 107 113 public static String fullNameToURLName(String clname, String appendName) { 114 clname = clname.replaceAll("::", "/"); 115 clname = clname.replace('[', '/'); 116 clname = clname.replace(']', '/'); 117 clname = clname + appendName; 118 if (clname.charAt(0) != '/') 119 clname = "/" + clname; 120 return clname; 121 } 122 123 } 124 | Popular Tags |