/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.jdbc.xa;

import org.jfox.pool.ObjectFactory;
import org.jfox.pool.PoolableObject;
import org.jfox.pool.SimpleObjectPool;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class XAConnectionPool extends SimpleObjectPool {

    public XAConnectionPool(ObjectFactory factory) {
        super((XAConnectionFactory) factory);
        ((XAConnectionFactory) factory).setPool(this);
    }

    public XAConnectionPool(ObjectFactory factory, int initNum, int maxRest) {
        super(factory, initNum, maxRest);
        ((XAConnectionFactory) factory).setPool(this);
    }

    public XAConnectionPool(ObjectFactory factory, int initNum, int maxRest, long timeout) {
        super(factory, initNum, maxRest, timeout);
    }

    /**
     * 通过与 XADataSource 默认不同的 user/password 来 getXAConnection
     * 这个 XAConnection 将不缓存
     *
     * @param user
     * @param password
     * @return
     * @throws Exception
     */
    PoolableObject retrieveObject(String user, String password) throws Exception {
        return ((XAConnectionFactory) factory).makeObject(user, password);
    }

    public static void main(String[] args) {

    }
}