1 8 9 package org.uddi4j.transport; 10 11 import java.util.Properties ; 12 13 18 public class TransportFactory { 19 20 public static final String PROPERTY_NAME = 21 "org.uddi4j.TransportClassName"; 22 23 public static final String DEFAULT_TRANSPORT_NAME= 24 "org.uddi4j.transport.ApacheSOAPTransport"; 25 26 private Transport transport = null; 27 static private String transportClassName = null; 28 29 Properties config = null; 30 31 36 private TransportFactory(Properties p) { 37 config = p; 38 } 39 40 53 public Transport getTransport() throws TransportException { 54 55 if (transport==null) { 56 transportClassName = config.getProperty(PROPERTY_NAME, DEFAULT_TRANSPORT_NAME); 57 try { 59 transport = (Transport)Class.forName(transportClassName).newInstance(); 60 if ("true".equals(config.getProperty("org.uddi4j.logEnabled"))) { 61 System.err.println("TransportFactory: Using transport name:" + transportClassName); 62 } 63 } catch (Exception e) { 64 throw new TransportException(e); 65 } 66 } 67 return transport; 68 } 69 70 75 static public TransportFactory newInstance() { 76 return new TransportFactory(System.getProperties()); 77 } 78 79 87 static public TransportFactory newInstance(Properties p) { 88 return new TransportFactory(p); 89 } 90 } 91 | Popular Tags |