[java-opensaml COMMIT] in /trunk: opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageSer...

noreply at shibboleth.net noreply at shibboleth.net
Thu Aug 13 14:45:13 EDT 2015


Author: scantor
Date: Thu Aug 13 14:45:13 2015
New Revision: 4318

URL: http://svn.shibboleth.net/view/java-opensaml?rev=4318&view=rev
Log:
IDP-594 - add a dirty-tracking feature to storage base class

Modified:
    trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
    trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java

Modified: trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java?rev=4318&r1=4317&r2=4318&view=diff
==============================================================================
--- trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java	(original)
+++ trunk/opensaml-storage-api/src/main/java/org/opensaml/storage/AbstractMapBackedStorageService.java	Thu Aug 13 14:45:13 2015
@@ -93,6 +93,7 @@
             log.trace("Inserted record '{}' in context '{}' with expiration '{}'",
                     new Object[] { key, context, expiration });
             
+            setDirty();
             return true;
             
         } finally {
@@ -219,6 +220,7 @@
             final Map<String, MutableStorageRecord> dataMap = contextMap.get(context);
             if (dataMap != null) {
                 if (reapWithLock(dataMap, System.currentTimeMillis())) {
+                    setDirty();
                     if (dataMap.isEmpty()) {
                         contextMap.remove(context);
                     }
@@ -231,18 +233,29 @@
     }
 
     /**
+     * Get the shared lock to synchronize access.
+     * 
+     * @return shared lock
+     */
+    @Nonnull protected abstract ReadWriteLock getLock();
+
+    /**
      * Get the map of contexts to manipulate during operations.
      * 
+     * <p>This method is guaranteed to be called under cover the lock returned by {{@link #getLock()}.</p>
+     * 
      * @return map of contexts to manipulate
      */
     @Nonnull @NonnullElements @Live protected abstract Map<String, Map<String, MutableStorageRecord>> getContextMap();
-    
-    /**
-     * Get the shared lock to synchronize access.
-     * 
-     * @return shared lock
-     */
-    @Nonnull protected abstract ReadWriteLock getLock();
+
+    /**
+     * A callback to indicate that data has been modified.
+     * 
+     * <p>This method is guaranteed to be called under cover the lock returned by {{@link #getLock()}.</p>
+     */
+    protected void setDirty() {
+        
+    }
     
     /**
      * Internal method to implement read functions.
@@ -340,6 +353,8 @@
                 throw new VersionMismatchException();
             }
     
+            setDirty();
+            
             if (value != null) {
                 record.setValue(value);
                 record.incrementVersion();
@@ -391,6 +406,7 @@
             } else if (version != null && record.getVersion() != version) {
                 throw new VersionMismatchException();
             } else {
+                setDirty();
                 dataMap.remove(key);
                 log.trace("Deleted record '{}' in context '{}'", key, context);
                 return true;

Modified: trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java?rev=4318&r1=4317&r2=4318&view=diff
==============================================================================
--- trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java	(original)
+++ trunk/opensaml-storage-impl/src/main/java/org/opensaml/storage/impl/ServletRequestScopedStorageService.java	Thu Aug 13 14:45:13 2015
@@ -56,7 +56,6 @@
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
 import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
-import net.shibboleth.utilities.java.support.annotation.constraint.Positive;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
 import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -218,44 +217,6 @@
         } else if (dataSealer == null || cookieManager == null) {
             throw new ComponentInitializationException("DataSealer and CookieManager must be set");
         }
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public boolean create(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key,
-            @Nonnull @NotEmpty final String value, @Nullable final Long expiration) throws IOException {
-        
-        if (super.create(context, key, value, expiration)) {

[... 66 lines stripped ...]


More information about the commits mailing list