1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.7.3.1'

This commit is contained in:
gnosygnu
2016-07-17 21:10:59 -04:00
parent b333db45f8
commit 7a851a41a5
290 changed files with 3048 additions and 2124 deletions

View File

@@ -17,26 +17,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.dbs; import gplx.*;
public class Db_conn_bldr {
private final Object thread_lock = new Object(); // LOCK:synchronized else random failures in Schema_mgr due to diff conn pointing to same db; DATE:2016-07-12
private Db_conn_bldr_wkr wkr;
public void Reg_default_sqlite() {wkr = Db_conn_bldr_wkr__sqlite.Instance; wkr.Clear_for_tests();}
public void Reg_default_mem() {wkr = Db_conn_bldr_wkr__mem.Instance; wkr.Clear_for_tests();}
public boolean Exists(Io_url url) {return wkr.Exists(url);}
public Db_conn Get(Io_url url) {return wkr.Get(url);}
public Db_conn New(Io_url url) {return wkr.New(url);}
public boolean Exists(Io_url url) {synchronized (thread_lock) {return wkr.Exists(url);}}
public Db_conn Get(Io_url url) {synchronized (thread_lock) {return wkr.Get(url);}}
public Db_conn New(Io_url url) {synchronized (thread_lock) {return wkr.New(url);}}
public Db_conn_bldr_data Get_or_new(Io_url url) {
boolean exists = wkr.Exists(url);
Db_conn conn = exists ? Get(url) : New(url);
return new Db_conn_bldr_data(conn, exists);
synchronized (thread_lock) {
boolean exists = wkr.Exists(url);
Db_conn conn = exists ? Get(url) : New(url);
return new Db_conn_bldr_data(conn, exists);
}
}
public Db_conn Get_or_noop(Io_url url) {
Db_conn rv = wkr.Get(url);
return rv == null ? Db_conn_.Noop : rv;
synchronized (thread_lock) {
Db_conn rv = wkr.Get(url);
return rv == null ? Db_conn_.Noop : rv;
}
}
public Db_conn Get_or_autocreate(boolean autocreate, Io_url url) {
boolean exists = wkr.Exists(url);
if (exists) return Get(url);
if (autocreate) return New(url);
else throw Err_.new_("dbs", "db does not exist", "url", url.Raw());
synchronized (thread_lock) {
boolean exists = wkr.Exists(url);
if (exists) return Get(url);
if (autocreate) return New(url);
else throw Err_.new_("dbs", "db does not exist", "url", url.Raw());
}
}
public static final Db_conn_bldr Instance = new Db_conn_bldr(); Db_conn_bldr() {}
}