? conf.getConnectionFactory2Properties()
: conf.getConnectionFactoryProperties());
Log jdbcLog = conf.getLog(JDBCConfiguration.LOG_JDBC);
Log sqlLog = conf.getLog(JDBCConfiguration.LOG_SQL);
DecoratingDataSource dds = new DecoratingDataSource(ds);
try {
// add user-defined decorators
List decorators = new ArrayList();
decorators.addAll(Arrays.asList(conf.
getConnectionDecoratorInstances()));
// add jdbc events decorator
JDBCEventConnectionDecorator ecd =
new JDBCEventConnectionDecorator();
Configurations.configureInstance(ecd, conf, opts);
JDBCListener[] listeners = conf.getJDBCListenerInstances();
for (int i = 0; i < listeners.length; i++)
ecd.addListener(listeners[i]);
decorators.add(ecd);
// ask the DriverDataSource to provide any additional decorators
if (ds instanceof DriverDataSource) {
List decs = ((DriverDataSource) ds).
createConnectionDecorators();
if (decs != null)
decorators.addAll(decs);
}
// logging decorator
LoggingConnectionDecorator lcd =
new LoggingConnectionDecorator();
Configurations.configureInstance(lcd, conf, opts);
lcd.getLogs().setJDBCLog(jdbcLog);
lcd.getLogs().setSQLLog(sqlLog);
decorators.add(lcd);
dds.addDecorators(decorators);
return dds;
} catch (OpenJPAException ke) {
throw ke;
} catch (Exception e) {
throw new StoreException(e).setFatal(true);