// 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 redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;
/*
 * Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.darkphoenixs.pool.redis;



/**
 * <p>Title: RedisConnectionFactoryOld</p>
 * <p>Description: Redis连接工厂</p>
 *
 * @author Victor
 * @version 1.0
 * @see ConnectionFactory
 * @since 2015年9月19日
 */
@Deprecated
class RedisConnectionFactoryOld implements ConnectionFactory<Jedis> {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 5692815845396189037L;

    /**
     * hostAndPort
     */
    private final AtomicReference<HostAndPort> hostAndPort = new AtomicReference<HostAndPort>();
    /**
     * connectionTimeout
     */
    private final int connectionTimeout;
    /**
     * soTimeout
     */
    private final int soTimeout;
    /**
     * password
     */
    private final String password;
    /**
     * database
     */
    private final int database;
    /**
     * clientName
     */
    private final String clientName;

    /**
     * <p>Title: RedisConnectionFactoryOld</p>
     * <p>Description: 构造方法</p>
     *
     * @param host              地址
     * @param port              端口
     * @param connectionTimeout 连接超时
     * @param soTimeout         超时时间
     * @param password          密码
     * @param database          数据库
     * @param clientName        客户端名称
     */
    public RedisConnectionFactoryOld(final String host, final int port, final int connectionTimeout,
                                     final int soTimeout, final String password, final int database, final String clientName) {
        this.hostAndPort.set(new HostAndPort(host, port));
        this.connectionTimeout = connectionTimeout;
        this.soTimeout = soTimeout;
        this.password = password;
        this.database = database;
        this.clientName = clientName;
    }

    /**
     * @param properties 参数配置
     * @since 1.2.1
     */
    public RedisConnectionFactoryOld(final Properties properties) {

        String address = properties.getProperty(RedisConfig.ADDRESS_PROPERTY);
        if (address == 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/redis/RedisConnectionFactoryOld.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 redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicReference;

/*
 * Copyright 2015-2016 Dark Phoenixs (Open-Source Organization).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.darkphoenixs.pool.redis;



/**
 * <p>Title: RedisConnectionFactoryOld</p>
 * <p>Description: Redis连接工厂</p>
 *
 * @author Victor
 * @version 1.0
 * @see ConnectionFactory
 * @since 2015年9月19日
 */
@Deprecated
class RedisConnectionFactoryOld implements ConnectionFactory<Jedis> {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 5692815845396189037L;

    /**
     * hostAndPort
     */
    private final AtomicReference<HostAndPort> hostAndPort = new AtomicReference<HostAndPort>();
    /**
     * connectionTimeout
     */
    private final int connectionTimeout;
    /**
     * soTimeout
     */
    private final int soTimeout;
    /**
     * password
     */
    private final String password;
    /**
     * database
     */
    private final int database;
    /**
     * clientName
     */
    private final String clientName;

    /**
     * <p>Title: RedisConnectionFactoryOld</p>
     * <p>Description: 构造方法</p>
     *
     * @param host              地址
     * @param port              端口
     * @param connectionTimeout 连接超时
     * @param soTimeout         超时时间
     * @param password          密码
     * @param database          数据库
     * @param clientName        客户端名称
     */
    public RedisConnectionFactoryOld(final String host, final int port, final int connectionTimeout,
                                     final int soTimeout, final String password, final int database, final String clientName) {
        this.hostAndPort.set(new HostAndPort(host, port));
        this.connectionTimeout = connectionTimeout;
        this.soTimeout = soTimeout;
        this.password = password;
        this.database = database;
        this.clientName = clientName;
    }

    /**
     * @param properties 参数配置
     * @since 1.2.1
     */
    public RedisConnectionFactoryOld(final Properties properties) {

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