use of org.apache.openejb.resource.jdbc.dbcp.DbcpDataSourceCreator in project tomee by apache.
the class DataSourceFactory method creator.
public static DataSourceCreator creator(final Object creatorName, final boolean willBeProxied) {
final DataSourceCreator defaultCreator = SystemInstance.get().getComponent(DataSourceCreator.class);
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (creatorName != null && creatorName instanceof String && (defaultCreator == null || !creatorName.equals(defaultCreator.getClass().getName()))) {
String clazz = KNOWN_CREATORS.get(creatorName);
if (clazz == null) {
clazz = (String) creatorName;
}
if (willBeProxied && clazz.equals(DefaultDataSourceCreator.class.getName())) {
clazz = DbcpDataSourceCreator.class.getName();
}
try {
return (DataSourceCreator) loader.loadClass(clazz).newInstance();
} catch (final Throwable e) {
LOGGER.error("can't create '" + creatorName + "', the default one will be used: " + defaultCreator, e);
}
}
if (defaultCreator instanceof DefaultDataSourceCreator && willBeProxied) {
// this one is proxiable, not the default one (legacy)
return new DbcpDataSourceCreator();
}
return defaultCreator;
}
Aggregations