/*
 * Copyright: (c) TBEE.ORG
 * Version:   $Revision: 1.5 $
 * Modified:  $Date: 2007/06/05 13:07:29 $
 * By:        $Author: toeukpap $
 */
package nl.reinders.bm;

import java.util.HashMap;
import java.util.Map;

import nl.reinders.jdbc.ReindersInformixAndLoggingDriver;


import oracle.toplink.essentials.config.CacheType;
import oracle.toplink.essentials.config.TargetServer;
import oracle.toplink.essentials.config.TopLinkProperties;

public class BM
{
	static org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(org.tbee.util.jdbc.Connection.class.getName() + ".sql"); 
	static public Map<String, Object> getEntityManagerFactorySettings(Class jdbcDriver, String jdbcUrl, String jdbcUsr, String jdbcPwd)
	{
		// setup the factory
		Map<String, Object> cfg = new HashMap<String, Object>();
		// always use ReindersInformixAndLoggingDriver so it hooks in the special informix connection class 
		cfg.put(TopLinkProperties.JDBC_DRIVER, ReindersInformixAndLoggingDriver.class.getName()); 
		cfg.put(TopLinkProperties.JDBC_URL, ReindersInformixAndLoggingDriver.PREFIX + jdbcDriver.getName() + "#" + jdbcUrl);
        cfg.put(TopLinkProperties.JDBC_USER, jdbcUsr); 
        cfg.put(TopLinkProperties.JDBC_PASSWORD, jdbcPwd); 
        cfg.put(TopLinkProperties.TARGET_DATABASE, "Informix");
        cfg.put(TopLinkProperties.TARGET_SERVER, TargetServer.None);
        cfg.put(TopLinkProperties.WEAVING, "true");
        cfg.put(TopLinkProperties.JDBC_READ_CONNECTIONS_MIN, "0");
        cfg.put(TopLinkProperties.JDBC_READ_CONNECTIONS_MAX, "1");
        cfg.put(TopLinkProperties.JDBC_READ_CONNECTIONS_SHARED, "true");
        cfg.put(TopLinkProperties.JDBC_WRITE_CONNECTIONS_MIN, "0");
        cfg.put(TopLinkProperties.JDBC_WRITE_CONNECTIONS_MAX, "1");
        cfg.put(TopLinkProperties.CACHE_TYPE_DEFAULT, CacheType.NONE); // no caching for now, maybe this can be eased later?
        //cfg.put(TopLinkProperties.LOGGING_LEVEL, "fine");
        cfg.put(TopLinkProperties.LOGGING_EXCEPTIONS, "true");
        return cfg;
	}
//	 we hook in the Reinders Driver so the connection will be set up correctly and for logging
//  cfg.put(TopLinkProperties.JDBC_DRIVER, nl.reinders.jdbc.ReindersInformixAndLoggingDriver.class.getName()); 
//  cfg.put(TopLinkProperties.JDBC_URL, nl.reinders.jdbc.ReindersInformixAndLoggingDriver.PREFIX + jdbcDriver.getName() + "#" + jdbcUrl);
}
