// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
// 
//     private static final long serialVersionUID = -6503525110247209484L;
// 
//     public ConnectionException() {
//         super();
//     }
// 
//     public ConnectionException(String message) {
//         super(message);
//     }
// 
//     public ConnectionException(Throwable e) {
//         super(e);
//     }
// 
//     public ConnectionException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
// 
//     /**
//      * <p>Title: createConnection</p>
//      * <p>Description: 创建连接</p>
//      *
//      * @return 连接
//      * @throws Exception
//      */
//     public abstract T createConnection() throws Exception;
// }


import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

        this.proxy = proxy;
        this.address = address;
        this.method = method;
        this.connectTimeout = connectTimeout;
        this.readTimeout = readTimeout;
        this.header = header;
    }

    /**
     * Instantiates a new Http connection factory.
     *
     * @param properties the properties
     */
    public HttpConnectionFactory(final Properties properties) {

        String proxyHost = properties.getProperty(HttpConfig.PROXY_HOST_PROPERTY);
        String proxyPort = properties.getProperty(HttpConfig.PROXY_PORT_PROPERTY);

        if (proxyHost != null && proxyPort != null)
            proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort)));
        else
            proxy = null;

        address = properties.getProperty(HttpConfig.HTTP_URL_PROPERTY);
        if (address == null)
            throw new ConnectionException("[" + HttpConfig.HTTP_URL_PROPERTY + "] is required !");

        method = properties.getProperty(HttpConfig.HTTP_METHOD_PROPERTY);
        if (method == null)
// Path: src/main/java/org/darkphoenixs/pool/ConnectionException.java
// public class ConnectionException extends RuntimeException {
// 
//     private static final long serialVersionUID = -6503525110247209484L;
// 
//     public ConnectionException() {
//         super();
//     }
// 
//     public ConnectionException(String message) {
//         super(message);
//     }
// 
//     public ConnectionException(Throwable e) {
//         super(e);
//     }
// 
//     public ConnectionException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/org/darkphoenixs/pool/ConnectionFactory.java
// public interface ConnectionFactory<T> extends PooledObjectFactory<T>, Serializable {
// 
//     /**
//      * <p>Title: createConnection</p>
//      * <p>Description: 创建连接</p>
//      *
//      * @return 连接
//      * @throws Exception
//      */
//     public abstract T createConnection() throws Exception;
// }


// Path: src/main/java/org/darkphoenixs/pool/http/HttpConnectionFactory.java
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.darkphoenixs.pool.ConnectionException;
import org.darkphoenixs.pool.ConnectionFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;


        this.proxy = proxy;
        this.address = address;
        this.method = method;
        this.connectTimeout = connectTimeout;
        this.readTimeout = readTimeout;
        this.header = header;
    }

    /**
     * Instantiates a new Http connection factory.
     *
     * @param properties the properties
     */
    public HttpConnectionFactory(final Properties properties) {

        String proxyHost = properties.getProperty(HttpConfig.PROXY_HOST_PROPERTY);
        String proxyPort = properties.getProperty(HttpConfig.PROXY_PORT_PROPERTY);

        if (proxyHost != null && proxyPort != null)
            proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort)));
        else
            proxy = null;

        address = properties.getProperty(HttpConfig.HTTP_URL_PROPERTY);
        if (address == null)
            throw new ConnectionException("[" + HttpConfig.HTTP_URL_PROPERTY + "] is required !");

        method = properties.getProperty(HttpConfig.HTTP_METHOD_PROPERTY);
        if (method == null)
            throw new ConnectionException("[" + HttpConfig.HTTP_METHOD_PROPERTY + "] is required !");