${database.allClassCopyright}package ${glPackageBaseCommon};
import javax.sql.DataSource;
import org.seasar.dbflute.DBDef;
import org.seasar.dbflute.cbean.ConditionBeanContext;
import org.seasar.dbflute.jdbc.DataSourceHandler;
import org.seasar.dbflute.s2dao.extension.TnSqlLogRegistry;
import org.seasar.dbflute.util.DfSystemUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author ${database.classAuthor}
*/
public class ${glDBFluteInitializer} {
// ===================================================================================
// Definition
// ==========
/** Log instance. */
private static final Log _log = LogFactory.getLog(${glDBFluteInitializer}.class);
// ===================================================================================
// Constructor
// ===========
#if ($database.isTargetContainerSeasar())
/**
* Constructor. And initialize various components.
*/
public ${glDBFluteInitializer}() {
_log.info("...Initializing DBFlute components");
handleSqlLogRegistry();
loadCoolClasses();
lockConfig();
}
#elseif ($database.isTargetContainerSpring())
/**
* Constructor. And initialize various components.
* @param dataSource The instance of data source. (NotNull)
*/
public ${glDBFluteInitializer}(DataSource dataSource) {
_log.info("...Initializing DBFlute components");
setupDataSourceHandler(dataSource);
lockConfig();
}
#else
/**
* Constructor. And initialize various components.
*/
public ${glDBFluteInitializer}() {
_log.info("...Initializing DBFlute components");
lockConfig();
}
#end
protected void handleSqlLogRegistry() { // for S2Container
if (${glDBFluteConfig}.getInstance().isUseSqlLogRegistry()) {
final StringBuilder sb = new StringBuilder();
sb.append("{SqlLog Information}").append(ln());
sb.append(" [SqlLogRegistry]").append(ln());
if (TnSqlLogRegistry.setupSqlLogRegistry()) {
sb.append(" ...Setting up sqlLogRegistry(org.seasar.extension.jdbc)").append(ln());
sb.append(" because the property 'useSqlLogRegistry' of the config of DBFlute is true");
} else {
sb.append(" The sqlLogRegistry(org.seasar.extension.jdbc) is not supported at the version");
}
_log.info(sb);
} else {
final Object sqlLogRegistry = TnSqlLogRegistry.findContainerSqlLogRegistry();
if (sqlLogRegistry != null) {
TnSqlLogRegistry.closeRegistration();
}
}
}
protected void loadCoolClasses() { // for S2Container
ConditionBeanContext.loadCoolClasses(); // against the ClassLoader Headache!
}
/**
* Set up the handler of data source to the configuration of DBFlute.
* If it uses commons-DBCP, it needs to arrange some for transaction.
*