[java-opensaml COMMIT] in /trunk/opensaml-saml-impl/src: main/java/org/opensaml/saml/metadata/resolver/impl/AbstractD...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Oct 14 23:32:01 EDT 2016
Author: putmanb
Date: Fri Oct 14 23:32:01 2016
New Revision: 4537
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4537&view=rev
Log:
OSJ-168: On-disk caching of dynamically acquired metadata
Add support for initing from the persistent cache in the background,
which is enabled by default.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolverTest.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java?rev=4537&r1=4536&r2=4537&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java Fri Oct 14 23:32:01 2016
@@ -112,6 +112,12 @@
/** Function for generating the String key used with the cache manager. */
private Function<EntityDescriptor, String> persistentCacheKeyGenerator;
+ /** Flag indicating whether should initialize from the persistent cache in the background. */
+ private boolean initializeFromPersistentCacheInBackground;
+
+ /** The delay in milliseconds after which to schedule the background initialization from the persistent cache. */
+ @Duration @Positive private Long backgroundInitializatonFromCacheDelay;
+
/** Predicate which determines whether a given entity should be loaded from the persistent cache
* at resolver initialization time. */
private Predicate<EntityDescriptor> initializationFromCachePredicate;
@@ -150,8 +156,62 @@
// Default to removing idle metadata
removeIdleEntityData = true;
- }
-
+
+ // Default to initializing from the the persistent cache in the background
+ initializeFromPersistentCacheInBackground = true;
+
+ // Default to 2 seconds.
+ backgroundInitializatonFromCacheDelay = 2*1000L;
+ }
+
+ /**
+ * Get the flag indicating whether should initialize from the persistent cache in the background.
+ *
+ * <p>Defaults to: true.</p>
+ *
+ * @return true if should init from the cache in background, false otherwise
+ */
+ public boolean isInitializeFromPersistentCacheInBackground() {
+ return initializeFromPersistentCacheInBackground;
+ }
+
+ /**
+ * Set the flag indicating whether should initialize from the persistent cache in the background.
+ *
+ * <p>Defaults to: true.</p>
+ *
+ * @param flag true if should init from the cache in the background, false otherwise
+ */
+ public void setInitializeFromPersistentCacheInBackground(boolean flag) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ initializeFromPersistentCacheInBackground = flag;
+ }
+
+ /**
+ * Get the delay in milliseconds after which to schedule the background initialization from the persistent cache.
+ *
+ * <p>Defaults to: 2 seconds.</p>
+ *
+ * @return the delay in milliseconds
+ */
+ @Nonnull public Long getBackgroundInitializatonFromCacheDelay() {
+ return backgroundInitializatonFromCacheDelay;
+ }
+
+ /**
+ * Set the delay in milliseconds after which to schedule the background initialization from the persistent cache.
+ *
+ * <p>Defaults to: 2 seconds.</p>
+ *
+ * @param delay the delay in milliseconds
+ */
+ public void setBackgroundInitializatonFromCacheDelay(@Nonnull final Long delay) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+ ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
+ backgroundInitializatonFromCacheDelay = delay;
+ }
+
/**
* Get the manager for the persistent cache store for resolved metadata.
*
@@ -490,6 +550,24 @@
* processed metadata in the backing store.
*
* <p>
+ * Equivalent to {@link #processNewMetadata(XMLObject, String, false)}.
+ * </p>
+ *
+ * @param root the root of the new metadata document being processed
+ * @param expectedEntityID the expected entityID of the resolved metadata
+ *
+ * @throws FilterException if there is a problem filtering the metadata
+ */
+ @Nonnull protected void processNewMetadata(@Nonnull final XMLObject root, @Nonnull final String expectedEntityID)
+ throws FilterException {
+ processNewMetadata(root, expectedEntityID, false);
+ }
+
+ /**
[... 216 lines stripped ...]
More information about the commits
mailing list