summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-08-26 01:11:29 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-08-26 01:11:29 +0000
commit00adea5bc6916b717132c72768ab3fea1b2a1a22 (patch)
treeba923df8ea6fcd0ebb17557cea16c355274a43ce /src/main/java/com/amazon/carbonado/repo
parent3c0acb2e614373452107aa54066d3398a54f338e (diff)
Added support for load and query trigger.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java5
-rw-r--r--src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java12
-rw-r--r--src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java38
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java12
4 files changed, 49 insertions, 18 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
index 2f1c35c..c8f636c 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorableGenerator.java
@@ -208,9 +208,10 @@ class JDBCStorableGenerator<S extends Storable> {
b.invokePrivate(EXTRACT_ALL_METHOD_NAME, null,
new TypeDesc[] {resultSetType, TypeDesc.INT});
- // Indicate that object is clean by calling markAllPropertiesClean.
+ // Indicate load completed in order to mark properties as valid and
+ // invoke load triggers.
b.loadThis();
- b.invokeVirtual(MARK_ALL_PROPERTIES_CLEAN, null, null);
+ b.invokeVirtual(StorableGenerator.LOAD_COMPLETED_METHOD_NAME, null, null);
b.returnVoid();
}
diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
index fd36c6e..19a6bab 100644
--- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java
@@ -189,6 +189,18 @@ class JDBCStorage<S extends Storable> extends StandardQueryFactory<S>
return mTriggerManager.getDeleteTrigger();
}
+ public Trigger<? super S> getLoadTrigger() {
+ return mTriggerManager.getLoadTrigger();
+ }
+
+ public void locallyDisableLoadTrigger() {
+ mTriggerManager.locallyDisableLoad();
+ }
+
+ public void locallyEnableLoadTrigger() {
+ mTriggerManager.locallyEnableLoad();
+ }
+
/**
* @param loader used to reload Blob outside original transaction
*/
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
index 7edec6b..7b9804d 100644
--- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
+++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java
@@ -230,7 +230,7 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
Log log = LogFactory.getLog(ReplicatedRepository.class);
- setReplicationDisabled(true);
+ setReplicationDisabled();
try {
Transaction txn = mRepository.enterTransaction();
try {
@@ -279,7 +279,7 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
txn.exit();
}
} finally {
- setReplicationDisabled(false);
+ setReplicationEnabled();
}
}
@@ -379,13 +379,13 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
* Deletes the replica entry with replication disabled.
*/
boolean tryDeleteReplica(Storable replica) throws PersistException {
- // Disable replication to prevent trigger from being invoked by
- // deleting replica.
- setReplicationDisabled(true);
+ // Prevent trigger from being invoked by deleting replica.
+ TriggerManager tm = mTriggerManager;
+ tm.locallyDisableDelete();
try {
return replica.tryDelete();
} finally {
- setReplicationDisabled(false);
+ tm.locallyEnableDelete();
}
}
@@ -393,23 +393,29 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> {
* Deletes the replica entry with replication disabled.
*/
void deleteReplica(Storable replica) throws PersistException {
- // Disable replication to prevent trigger from being invoked by
- // deleting replica.
- setReplicationDisabled(true);
+ // Prevent trigger from being invoked by deleting replica.
+ TriggerManager tm = mTriggerManager;
+ tm.locallyDisableDelete();
try {
replica.delete();
} finally {
- setReplicationDisabled(false);
+ tm.locallyEnableDelete();
}
}
- void setReplicationDisabled(boolean disabled) {
+ void setReplicationDisabled() {
// This method disables not only this trigger, but all triggers added
// to manager.
- if (disabled) {
- mTriggerManager.localDisable();
- } else {
- mTriggerManager.localEnable();
- }
+ TriggerManager tm = mTriggerManager;
+ tm.locallyDisableInsert();
+ tm.locallyDisableUpdate();
+ tm.locallyDisableDelete();
+ }
+
+ void setReplicationEnabled() {
+ TriggerManager tm = mTriggerManager;
+ tm.locallyEnableInsert();
+ tm.locallyEnableUpdate();
+ tm.locallyEnableDelete();
}
}
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
index 03874aa..1f14c4f 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
@@ -1122,5 +1122,17 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
public Trigger<? super S> getDeleteTrigger() {
return mStorage.mTriggerManager.getDeleteTrigger();
}
+
+ public Trigger<? super S> getLoadTrigger() {
+ return mStorage.mTriggerManager.getLoadTrigger();
+ }
+
+ public void locallyDisableLoadTrigger() {
+ mStorage.mTriggerManager.locallyDisableLoad();
+ }
+
+ public void locallyEnableLoadTrigger() {
+ mStorage.mTriggerManager.locallyEnableLoad();
+ }
}
}