summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-04-21 23:45:09 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-04-21 23:45:09 +0000
commit43c536a71cf108c225fe9e94d554c3d8c240b4e0 (patch)
treeb54e6dd9aa9e4826ff10f006f07a15175cc8cc5a /src/main/java
parent59185851eda16b725d47a56ec71d954944522400 (diff)
Support database name remapping.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java16
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java6
2 files changed, 19 insertions, 3 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
index 243fffc..a56a91d 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
@@ -365,7 +365,11 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
String dbFileName = dbName;
- if (singleFileName != null) {
+ if (singleFileName == null) {
+ if (mDatabaseHook != null) {
+ dbFileName = mDatabaseHook.databaseName(dbName);
+ }
+ } else {
dbFileName = singleFileName;
}
@@ -379,7 +383,7 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
/**
* Returns null if name should not be used.
*/
- String getDatabaseName(final String dbName) {
+ String getDatabaseName(String dbName) {
if (mFileNameMap == null) {
return null;
}
@@ -387,7 +391,13 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
if (name == null && dbName != null) {
name = mFileNameMap.get(null);
}
- return name == null ? null : dbName;
+ if (name == null) {
+ return null;
+ }
+ if (mDatabaseHook != null) {
+ dbName = mDatabaseHook.databaseName(dbName);
+ }
+ return dbName;
}
StorableCodecFactory getStorableCodecFactory() {
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
index 1def43e..995fada 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepositoryBuilder.java
@@ -796,6 +796,12 @@ public class BDBRepositoryBuilder extends AbstractRepositoryBuilder {
public static interface DatabaseHook {
/**
+ * Returns an appropriate database name for the given type. Simply
+ * return the type name as-is to support default behavior.
+ */
+ String databaseName(String typeName);
+
+ /**
* Called right before database is opened.
*
* @param db reference to database or config - actual type depends on BDB