1 package com.maverick.http; 2 3 import java.io.IOException ; 4 import java.net.InetAddress ; 5 import java.net.UnknownHostException ; 6 7 public class SocketWithLayeredTransportFactory { 8 9 static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(SocketWithLayeredTransportFactory.class); 11 13 static SocketWithLayeredTransportFactory instance = null; 14 static Class socketFactoryImpl = SocketWithLayeredTransportFactory.class; 15 16 public SocketWithLayeredTransport createSocket(String arg0, int arg1) throws IOException , 17 UnknownHostException { 18 return new SocketWithLayeredTransport(arg0, arg1); 19 } 20 21 public SocketWithLayeredTransport createSocket(InetAddress arg0, int arg1) throws IOException { 22 return new SocketWithLayeredTransport(arg0, arg1); 23 } 24 25 26 public static SocketWithLayeredTransportFactory getDefault() { 27 28 try { 29 return instance==null ? instance = (SocketWithLayeredTransportFactory) socketFactoryImpl.newInstance() : instance; 30 } catch (Exception e) { 31 log.error("Failed to create instance of socket factory" + socketFactoryImpl.getName(), e); 33 return instance = new SocketWithLayeredTransportFactory(); 35 } 36 } 37 38 public static void setFactoryImpl(Class socketFactoryImpl) { 39 SocketWithLayeredTransportFactory.socketFactoryImpl = socketFactoryImpl; 40 } 41 } 42 | Popular Tags |