cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1065004 - in /cayenne/main/trunk/framework/cayenne-lifecycle/src: main/java/org/apache/cayenne/lifecycle/audit/ test/java/org/apache/cayenne/lifecycle/audit/
Date Sat, 29 Jan 2011 11:50:57 GMT
Author: aadamchik
Date: Sat Jan 29 11:50:57 2011
New Revision: 1065004

URL: http://svn.apache.org/viewvc?rev=1065004&view=rev
Log:
 CAY-1534 cayenne-lifecycle: implement AuditableFilter

collapse multiple audit ops

Modified:
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java?rev=1065004&r1=1065003&r2=1065004&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableAggregator.java
Sat Jan 29 11:50:57 2011
@@ -60,7 +60,7 @@ class AuditableAggregator {
         }
     }
 
-    void postCommit() {
+    void postSync() {
         for (Entry<Object, AuditableOperation> op : ops.entrySet()) {
             delegate.audit(op.getKey(), op.getValue());
         }

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java?rev=1065004&r1=1065003&r2=1065004&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/AuditableFilter.java
Sat Jan 29 11:50:57 2011
@@ -38,11 +38,12 @@ import org.apache.cayenne.query.Query;
  */
 public class AuditableFilter implements DataChannelFilter {
 
-    private final ThreadLocal<AuditableAggregator> aggregator = new ThreadLocal<AuditableAggregator>();
+    private ThreadLocal<AuditableAggregator> aggregator;
     protected AuditableProcessor processor;
 
     public AuditableFilter(AuditableProcessor processor) {
         this.processor = processor;
+        this.aggregator = new ThreadLocal<AuditableAggregator>();
     }
 
     public void init(DataChannel channel) {
@@ -66,6 +67,8 @@ public class AuditableFilter implements 
             GraphDiff response = filterChain
                     .onSync(originatingContext, changes, syncType);
 
+            postSync();
+
             return response;
         }
         finally {
@@ -73,6 +76,13 @@ public class AuditableFilter implements 
         }
     }
 
+    void postSync() {
+        AuditableAggregator aggregator = this.aggregator.get();
+        if (aggregator != null) {
+            aggregator.postSync();
+        }
+    }
+
     private AuditableAggregator getAggregator() {
         AuditableAggregator aggregator = this.aggregator.get();
         if (aggregator == null) {

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java?rev=1065004&r1=1065003&r2=1065004&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/test/java/org/apache/cayenne/lifecycle/audit/AuditableFilterTest.java
Sat Jan 29 11:50:57 2011
@@ -39,6 +39,7 @@ public class AuditableFilterTest extends
         AuditableFilter filter = new AuditableFilter(processor);
         Object audited = new Object();
         filter.insertAudit(audited);
+        filter.postSync();
 
         verify(processor).audit(audited, AuditableOperation.INSERT);
     }
@@ -49,6 +50,7 @@ public class AuditableFilterTest extends
         AuditableFilter filter = new AuditableFilter(processor);
         Object audited = new Object();
         filter.deleteAudit(audited);
+        filter.postSync();
 
         verify(processor).audit(audited, AuditableOperation.DELETE);
     }
@@ -59,6 +61,7 @@ public class AuditableFilterTest extends
         AuditableFilter filter = new AuditableFilter(processor);
         Object audited = new Object();
         filter.updateAudit(audited);
+        filter.postSync();
 
         verify(processor).audit(audited, AuditableOperation.UPDATE);
     }
@@ -72,6 +75,7 @@ public class AuditableFilterTest extends
         DataObject audited = new MockAuditableChild();
         audited.writeProperty("parent", auditedParent);
         filter.updateAuditChild(audited);
+        filter.postSync();
 
         verify(processor).audit(auditedParent, AuditableOperation.UPDATE);
     }



Mime
View raw message