KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > maverick > ssl > SSLTransportFactory


1 package com.maverick.ssl;
2
3 public class SSLTransportFactory {
4     
5     static Class JavaDoc impl;
6     
7     static {
8         
9         /**
10          * We now default to using SSLEngine based implementation if
11          * Java version is 1.5 or greater.
12          */

13         try {
14             Class.forName("javax.net.ssl.SSLEngine");
15             impl = Class.forName("com.maverick.ssl.SSLTransportJCE");
16         } catch(Throwable JavaDoc t) {
17             impl = SSLTransportImpl.class;
18         }
19     }
20     
21     
22     //#ifdef DEBUG
23
static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(SSLTransportFactory.class);
24     //#endif
25

26     public static void setTransportImpl(Class JavaDoc impl) {
27         SSLTransportFactory.impl = impl;
28     }
29     
30     
31     public static SSLTransport newInstance() {
32         try {
33             return (SSLTransport) impl.newInstance();
34         } catch(Throwable JavaDoc t) {
35             //#ifdef DEBUG
36
log.error("Failed to create SSLTransport instance", t);
37             //#endif
38
return new SSLTransportImpl();
39         }
40     }
41
42 }
43
Popular Tags