aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/iciql/Db.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2014-11-10 11:59:09 -0500
committerJames Moger <james.moger@gitblit.com>2014-11-10 21:46:37 -0500
commita6df2de41953e10db1527e54acd734c0f0a1fa28 (patch)
treead3a86dc2a54cf3ac9418e0e5e86f396f4e1dfb0 /src/main/java/com/iciql/Db.java
parentc1d81bcdfc948b417964c6b69be2ee5801e5e1c9 (diff)
downloadiciql-a6df2de41953e10db1527e54acd734c0f0a1fa28.tar.gz
iciql-a6df2de41953e10db1527e54acd734c0f0a1fa28.zip
Implement DAO externalized statement loading based on runtime Mode
Diffstat (limited to 'src/main/java/com/iciql/Db.java')
-rw-r--r--src/main/java/com/iciql/Db.java33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main/java/com/iciql/Db.java b/src/main/java/com/iciql/Db.java
index 794417e..7413c8f 100644
--- a/src/main/java/com/iciql/Db.java
+++ b/src/main/java/com/iciql/Db.java
@@ -74,6 +74,7 @@ public class Db implements AutoCloseable {
private boolean skipCreate;
private boolean autoSavePoint = true;
+ private DaoStatementProvider daoStatementProvider;
static {
TOKENS = Collections.synchronizedMap(new WeakIdentityHashMap<Object, Token>());
@@ -102,6 +103,7 @@ public class Db implements AutoCloseable {
}
dialect = getDialect(databaseName, conn.getClass().getName());
dialect.configureDialect(this);
+ daoStatementProvider = new NoExternalDaoStatements();
}
/**
@@ -237,7 +239,30 @@ public class Db implements AutoCloseable {
*/
@SuppressWarnings("resource")
public <X extends Dao> X open(Class<X> daoClass) {
- return new DaoProxy<X>(this, daoClass).buildProxy();
+ return new DaoProxy<X>(this, daoClass).build();
+ }
+
+ /**
+ * Returns the DAO statement provider.
+ *
+ * @return the DAO statement provider
+ */
+ public DaoStatementProvider getDaoStatementProvider() {
+ return daoStatementProvider;
+ }
+
+ /**
+ * Sets the DAO statement provider.
+ *
+ * @param statementProvider
+ */
+ public void setDaoStatementProvider(DaoStatementProvider statementProvider) {
+ if (statementProvider == null) {
+ throw new IciqlException("You must provide a valid {0} instance!",
+ DaoStatementProvider.class.getSimpleName());
+ }
+
+ this.daoStatementProvider = statementProvider;
}
/**
@@ -841,14 +866,12 @@ public class Db implements AutoCloseable {
}
/**
- *
- * @author James Moger
- *
+ * Default DAO statement provider.
*/
class NoExternalDaoStatements implements DaoStatementProvider {
@Override
- public String getStatement(String idOrStatement) {
+ public String getStatement(String idOrStatement, Mode mode) {
return idOrStatement;
}