package com.agilex.healthcare.schedulingmanager.mdws.connection;

public class QueryConnectionManagerFactory {
	private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(QueryConnectionManagerFactory.class);

	private static QueryConnectionManager connectionManager;
	private static PoolConfiguration poolConfiguration;

	private QueryConnectionManagerFactory() {}

	public static QueryConnectionManager getInstance() {
		if (connectionManager != null)
			return connectionManager;

		if (poolConfiguration == null)
			getConfiguration();

		connectionManager = new BasicQueryConnectionManager();
		return connectionManager;
	}

	private static PoolConfiguration getConfiguration() {
		if (poolConfiguration == null) {
			logger.debug("Loading connection pool configuration");
			poolConfiguration = new PoolConfiguration();
			poolConfiguration.load();
		}
		return poolConfiguration;
	}
}
