public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataResolver implements DynamicMetadataResolver
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractDynamicMetadataResolver.BackingStoreCleanupSweeper
Background maintenance task which cleans expired and idle metadata from the backing store, and removes
orphaned entity management data.
|
protected class |
AbstractDynamicMetadataResolver.DynamicEntityBackingStore
Specialized entity backing store implementation for dynamic metadata resolvers.
|
protected class |
AbstractDynamicMetadataResolver.EntityManagementData
Class holding per-entity management data.
|
AbstractMetadataResolver.EntityBackingStore
Constructor and Description |
---|
AbstractDynamicMetadataResolver(Timer backgroundTaskTimer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected org.joda.time.DateTime |
computeExpirationTime(EntityDescriptor entityDescriptor,
org.joda.time.DateTime now)
Compute the effective expiration time for the specified metadata.
|
protected org.joda.time.DateTime |
computeRefreshTriggerTime(org.joda.time.DateTime expirationTime,
org.joda.time.DateTime nowDateTime)
Compute the refresh trigger time.
|
protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore |
createNewBackingStore()
Create a new backing store instance for EntityDescriptor data.
|
protected void |
doDestroy()
Performs component specific destruction logic.
|
protected abstract XMLObject |
fetchFromOriginSource(CriteriaSet criteria)
Fetch the metadata from the origin source.
|
protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore |
getBackingStore()
Get the EntityDescriptor backing store currently in use by the metadata resolver.
|
Long |
getCleanupTaskInterval()
Get the interval in milliseconds at which the cleanup task should run.
|
Long |
getMaxCacheDuration()
Get the maximum cache duration for metadata.
|
Long |
getMaxIdleEntityData()
Get the maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
before it is removed.
|
Long |
getMinCacheDuration()
Get the minimum cache duration for metadata.
|
Float |
getRefreshDelayFactor()
Gets the delay factor used to compute the next refresh time.
|
protected void |
initMetadataResolver()
Subclasses should override this method to perform any initialization logic necessary.
|
boolean |
isRemoveIdleEntityData()
Get the flag indicating whether idle entity data should be removed.
|
protected List<EntityDescriptor> |
lookupEntityID(String entityID)
Get list of descriptors matching an entityID.
|
protected void |
preProcessEntityDescriptor(EntityDescriptor entityDescriptor,
AbstractMetadataResolver.EntityBackingStore backingStore)
Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.
|
protected void |
processNewMetadata(XMLObject root,
String expectedEntityID)
Process the specified new metadata document, including metadata filtering, and store the
processed metadata in the backing store.
|
Iterable<EntityDescriptor> |
resolve(CriteriaSet criteria)
Process the specified criteria and return the resulting instances of the product type
which satisfy the criteria.
|
protected Iterable<EntityDescriptor> |
resolveFromOriginSource(CriteriaSet criteria)
Fetch metadata from an origin source based on the input criteria, store it in the backing store
and then return it.
|
void |
setCleanupTaskInterval(Long interval)
Set the interval in milliseconds at which the cleanup task should run.
|
void |
setMaxCacheDuration(Long duration)
Set the maximum cache duration for metadata.
|
void |
setMaxIdleEntityData(Long max)
Set the maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
before it is removed.
|
void |
setMinCacheDuration(Long duration)
Set the minimum cache duration for metadata.
|
void |
setRefreshDelayFactor(Float factor)
Sets the delay factor used to compute the next refresh time.
|
void |
setRemoveIdleEntityData(boolean flag)
Set the flag indicating whether idle entity data should be removed.
|
protected boolean |
shouldAttemptRefresh(AbstractDynamicMetadataResolver.EntityManagementData mgmtData)
Determine whether should attempt to refresh the metadata, based on stored refresh trigger time.
|
doInitialize, filterMetadata, getMetadataFilter, getParserPool, getUnmarshallerFactory, indexEntityDescriptor, isFailFastInitialization, isRequireValidMetadata, isValid, lookupIndexedEntityID, preProcessEntitiesDescriptor, releaseMetadataDOM, removeByEntityID, resolveSingle, setBackingStore, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, unmarshallMetadata
setId
getId
destroy, initialize, isDestroyed, isInitialized
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata
resolveSingle
getId
@Nonnull public Long getMinCacheDuration()
Defaults to: 10 minutes.
public void setMinCacheDuration(@Nonnull Long duration)
Defaults to: 10 minutes.
duration
- the minimum cache duration, in milliseconds@Nonnull public Long getMaxCacheDuration()
Defaults to: 8 hours.
public void setMaxCacheDuration(@Nonnull Long duration)
Defaults to: 8 hours.
duration
- the maximum cache duration, in millisecondspublic Float getRefreshDelayFactor()
Defaults to: 0.75.
public void setRefreshDelayFactor(Float factor)
Defaults to: 0.75.
factor
- delay factor used to compute the next refresh timepublic boolean isRemoveIdleEntityData()
public void setRemoveIdleEntityData(boolean flag)
flag
- true if idle entity data should be removed, false otherwise@Nonnull public Long getMaxIdleEntityData()
Defaults to: 8 hours.
public void setMaxIdleEntityData(@Nonnull Long max)
Defaults to: 8 hours.
max
- the maximum entity data idle time, in milliseconds@Nonnull public Long getCleanupTaskInterval()
Defaults to: 30 minutes.
public void setCleanupTaskInterval(@Nonnull Long interval)
Defaults to: 30 minutes.
interval
- the interval to set, in milliseconds@Nonnull public Iterable<EntityDescriptor> resolve(@Nonnull CriteriaSet criteria) throws ResolverException
resolve
in interface Resolver<EntityDescriptor,CriteriaSet>
criteria
- the criteria to evaluate or processResolverException
- thrown if there is an error processing the specified criteria@Nonnull @NonnullElements protected Iterable<EntityDescriptor> resolveFromOriginSource(@Nonnull CriteriaSet criteria) throws ResolverException
criteria
- the input criteria setResolverException
- if there is a fatal error attempting to resolve the metadata@Nullable protected abstract XMLObject fetchFromOriginSource(@Nonnull CriteriaSet criteria) throws IOException
criteria
- the input criteria setIOException
- if there is a fatal error fetching metadata from the origin source@Nonnull @NonnullElements protected List<EntityDescriptor> lookupEntityID(@Nonnull String entityID) throws ResolverException
lookupEntityID
in class AbstractMetadataResolver
entityID
- entityID to lookupResolverException
- if an error occurs@Nonnull protected void processNewMetadata(@Nonnull XMLObject root, @Nonnull String expectedEntityID) throws FilterException
In order to be processed successfully, the metadata (after filtering) must be an instance of
EntityDescriptor
and its entityID
value must match the value supplied
as the required expectedEntityID
argument.
root
- the root of the new metadata document being processedexpectedEntityID
- the expected entityID of the resolved metadataFilterException
- if there is a problem filtering the metadataprotected void preProcessEntityDescriptor(@Nonnull EntityDescriptor entityDescriptor, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore)
preProcessEntityDescriptor
in class AbstractMetadataResolver
entityDescriptor
- the target entity descriptor to processbackingStore
- the backing store instance to update@Nonnull protected org.joda.time.DateTime computeExpirationTime(@Nonnull EntityDescriptor entityDescriptor, @Nonnull org.joda.time.DateTime now)
entityDescriptor
- the EntityDescriptor instance to evaluatenow
- the current date time instant@Nonnull protected org.joda.time.DateTime computeRefreshTriggerTime(@Nullable org.joda.time.DateTime expirationTime, @Nonnull org.joda.time.DateTime nowDateTime)
expirationTime
- the time at which the metadata effectively expiresnowDateTime
- the current date time instantprotected boolean shouldAttemptRefresh(@Nonnull AbstractDynamicMetadataResolver.EntityManagementData mgmtData)
mgmtData
- the entity'd management data@Nonnull protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore createNewBackingStore()
AbstractMetadataResolver.setBackingStore(EntityBackingStore)
to make it the effective
instance in use.createNewBackingStore
in class AbstractMetadataResolver
@NonnullAfterInit protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore getBackingStore()
getBackingStore
in class AbstractMetadataResolver
protected void initMetadataResolver() throws ComponentInitializationException
initMetadataResolver
in class AbstractMetadataResolver
ComponentInitializationException
- thrown if there is a problem initializing the providerprotected void doDestroy()
doDestroy
in class AbstractMetadataResolver
Copyright © 2016 JBoss by Red Hat. All rights reserved.