public DataSource createDataSource ( Properties props , String dataSourceID ) throws SQLException { lock . readLock ( ) . lock ( ) ; try { if ( ! isInitialized ) try { // Switch to write lock for lazy initialization lock . readLock ( ) . unlock ( ) ; lock . writeLock ( ) . lock ( ) ; if ( ! isInitialized ) { if ( ! loadFromApp ( ) ) classloader = AdapterUtil . getClassLoaderWithPriv ( sharedLib ) ; isInitialized = true ; } } finally { // Downgrade to read lock for rest of method lock . readLock ( ) . lock ( ) ; lock . writeLock ( ) . unlock ( ) ; } String className = ( String ) properties . get ( DataSource . class . getName ( ) ) ; if ( className == null ) { String vendorPropertiesPID = props instanceof PropertyService ? ( ( PropertyService ) props ) . getFactoryPID ( ) : PropertyService . FACTORY_PID ; className = JDBCDrivers . getDataSourceClassName ( vendorPropertiesPID ) ; if ( className == null ) { className = JDBCDrivers . getDataSourceClassName ( getClasspath ( sharedLib , true ) ) ; if ( className == null ) { Set < String > packagesSearched = new LinkedHashSet < String > ( ) ; SimpleEntry < Integer , String > dsEntry = JDBCDrivers . inferDataSourceClassFromDriver // ( classloader , packagesSearched , JDBCDrivers . DATA_SOURCE ) ; className = dsEntry == null ? null : dsEntry . getValue ( ) ; if ( className == null ) throw classNotFound ( DataSource . class . getName ( ) , packagesSearched , dataSourceID , null ) ; } } } return create ( className , props , dataSourceID ) ; } finally { lock . readLock ( ) . unlock ( ) ; } }
Create a DataSource