1 55 package org.jboss.axis.components.net; 56 57 import java.util.HashMap ; 58 import java.util.Hashtable ; 59 60 import org.jboss.axis.AxisProperties; 61 import org.jboss.logging.Logger; 62 63 69 public class SocketFactoryFactory 70 { 71 72 75 private static Logger log = Logger.getLogger(SocketFactoryFactory.class.getName()); 76 77 80 private static Hashtable factories = new Hashtable (); 81 82 private static final Class classes[] = new Class []{HashMap .class}; 83 84 85 static 86 { 87 AxisProperties.setClassOverrideProperty(SocketFactory.class, 88 "axis.socketFactory"); 89 90 AxisProperties.setClassDefault(SocketFactory.class, 91 "org.jboss.axis.components.net.DefaultSocketFactory"); 92 93 AxisProperties.setClassOverrideProperty(SecureSocketFactory.class, 94 "axis.socketSecureFactory"); 95 96 boolean jdk14 = false; 97 try 98 { 99 Class.forName("javax.net.ssl.SSLContext"); 100 jdk14 = true; 101 } 102 catch (ClassNotFoundException e) {} 103 104 AxisProperties.setClassDefault(SecureSocketFactory.class , 105 (jdk14) ? "org.jboss.axis.components.net.JSSE14SocketFactory" : "org.jboss.axis.components.net.JSSESocketFactory"); 106 } 107 108 115 public static synchronized SocketFactory getFactory(String protocol, 116 HashMap options) 117 { 118 SocketFactory theFactory = (SocketFactory)factories.get(protocol); 119 120 if (theFactory == null) 121 { 122 Object objects[] = new Object []{options}; 123 124 if (protocol.equalsIgnoreCase("http")) 125 { 126 theFactory = (SocketFactory) 127 AxisProperties.newInstance(SocketFactory.class, classes, objects); 128 } 129 else if (protocol.equalsIgnoreCase("https")) 130 { 131 theFactory = (SecureSocketFactory) 132 AxisProperties.newInstance(SecureSocketFactory.class, classes, objects); 133 } 134 135 if (theFactory != null && options.size() == 0) 138 { 139 factories.put(protocol, theFactory); 140 } 141 } 142 return theFactory; 143 } 144 } 145 | Popular Tags |