public abstract class AbstractReloadingMetadataProvider extends AbstractObservableMetadataProvider
getMaxRefreshDelay()
value is used. Otherwise, the earliest refresh interval of the metadata file is checked
by looking for the earliest of all the validUntil attributes and cacheDuration attributes. If that refresh interval
is larger than the max refresh delay then getMaxRefreshDelay()
is used. If that number is smaller than the
min refresh delay then getMinRefreshDelay()
is used. Otherwise the calculated refresh delay multiplied by
getRefreshDelayFactor()
is used. By using this factor, the provider will attempt to be refresh before the
cache actually expires, allowing a some room for error and recovery. Assuming the factor is not exceedingly close to
1.0 and a min refresh delay that is not overly large, this refresh will likely occur a few times before the cache
expires.ObservableMetadataProvider.Observer
unmarshallerFactory
修飾子 | コンストラクタと説明 |
---|---|
protected |
AbstractReloadingMetadataProvider()
Constructor.
|
protected |
AbstractReloadingMetadataProvider(Timer backgroundTaskTimer)
Constructor.
|
修飾子とタイプ | メソッドと説明 |
---|---|
protected long |
computeNextRefreshDelay(org.joda.time.DateTime expectedExpiration)
Computes the delay until the next refresh time based on the current metadata's expiration time and the refresh
interval floor.
|
void |
destroy()
Destroys the metadata provider and frees any resources current held by it.
|
protected XMLObject |
doGetMetadata()
Gets the metadata currently held by the provider.
|
protected void |
doInitialization()
Subclasses should override this method to perform any initialization logic necessary.
|
protected abstract byte[] |
fetchMetadata()
Fetches metadata from a source.
|
org.joda.time.DateTime |
getExpirationTime()
Gets the time when the currently cached metadata expires.
|
org.joda.time.DateTime |
getLastRefresh()
Gets the time the last refresh cycle occurred.
|
org.joda.time.DateTime |
getLastUpdate()
Gets the time that the currently available metadata was last updated.
|
long |
getMaxRefreshDelay()
Gets the maximum amount of time, in milliseconds, between refresh intervals.
|
protected abstract String |
getMetadataIdentifier()
Gets an identifier which may be used to distinguish this metadata in logging statements.
|
int |
getMinRefreshDelay()
Gets the minimum amount of time, in milliseconds, between refreshes.
|
org.joda.time.DateTime |
getNextRefresh()
Gets the time when the next refresh cycle will occur.
|
float |
getRefreshDelayFactor()
Gets the delay factor used to compute the next refresh time.
|
protected byte[] |
inputstreamToByteArray(InputStream ins)
Converts an InputStream into a byte array.
|
protected void |
postProcessMetadata(byte[] metadataBytes,
Document metadataDom,
XMLObject metadata)
Post-processing hook called after new metadata has been unmarshalled, filtered, and the DOM released (from the
XMLObject ) but before the metadata is saved off. |
protected void |
processCachedMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart)
Processes a cached metadata document in order to determine, and schedule, the next time it should be refreshed.
|
protected void |
processNewMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes)
Process a new metadata document.
|
protected void |
processNonExpiredMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes,
XMLObject metadata)
Processes metadata that has been determined to be valid at the time it was fetched.
|
protected void |
processPreExpiredMetadata(String metadataIdentifier,
org.joda.time.DateTime refreshStart,
byte[] metadataBytes,
XMLObject metadata)
Processes metadata that has been determined to be invalid (usually because it's already expired) at the time it
was fetched.
|
void |
refresh()
Refreshes the metadata from its source.
|
void |
setMaxRefreshDelay(long delay)
Sets the maximum amount of time, in milliseconds, between refresh intervals.
|
void |
setMinRefreshDelay(int delay)
Sets the minimum amount of time, in milliseconds, between refreshes.
|
void |
setRefreshDelayFactor(float factor)
Sets the delay factor used to compute the next refresh time.
|
protected XMLObject |
unmarshallMetadata(byte[] metadataBytes)
Unmarshalls the given metadata bytes.
|
emitChangeEvent, getObservers
clearDescriptorIndex, doGetEntitiesDescriptor, doGetEntityDescriptor, doGetRole, doGetRole, filterMetadata, getEntitiesDescriptor, getEntitiesDescriptorByName, getEntityDescriptor, getEntityDescriptorById, getEntityDescriptorById, getMetadata, getParserPool, getRole, getRole, initialize, isFailFastInitialization, isInitialized, isValid, releaseMetadataDOM, setFailFastInitialization, setInitialized, setParserPool, unmarshallMetadata
getMetadataFilter, requireValidMetadata, setMetadataFilter, setRequireValidMetadata
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getEntitiesDescriptor, getEntityDescriptor, getMetadata, getMetadataFilter, getRole, getRole, requireValidMetadata, setMetadataFilter, setRequireValidMetadata
protected AbstractReloadingMetadataProvider()
protected AbstractReloadingMetadataProvider(Timer backgroundTaskTimer)
backgroundTaskTimer
- time used to schedule background refresh taskspublic org.joda.time.DateTime getExpirationTime()
public org.joda.time.DateTime getLastUpdate()
getLastUpdate()
is the metadata was known not to have changed during the last refresh
cycle.public org.joda.time.DateTime getLastRefresh()
public org.joda.time.DateTime getNextRefresh()
public long getMaxRefreshDelay()
public void setMaxRefreshDelay(long delay)
delay
- maximum amount of time, in milliseconds, between refresh intervalspublic float getRefreshDelayFactor()
public void setRefreshDelayFactor(float factor)
factor
- delay factor used to compute the next refresh timepublic int getMinRefreshDelay()
public void setMinRefreshDelay(int delay)
delay
- minimum amount of time, in milliseconds, between refreshespublic void destroy()
destroy
クラス内 AbstractObservableMetadataProvider
protected XMLObject doGetMetadata() throws MetadataProviderException
doGetMetadata
クラス内 AbstractMetadataProvider
MetadataProviderException
- thrown if there is a problem retrieving the metadataprotected void doInitialization() throws MetadataProviderException
doInitialization
クラス内 AbstractMetadataProvider
MetadataProviderException
- thrown if there is a problem initializing the providerpublic void refresh() throws MetadataProviderException
MetadataProviderException
- thrown is there is a problem retrieving and processing the metadataprotected abstract String getMetadataIdentifier()
protected abstract byte[] fetchMetadata() throws MetadataProviderException
MetadataProviderException
- thrown if there is a problem fetching the metadataprotected XMLObject unmarshallMetadata(byte[] metadataBytes) throws MetadataProviderException
metadataBytes
- raw metadata bytesMetadataProviderException
- thrown if the metadata can not be unmarshalledprotected void processCachedMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart) throws MetadataProviderException
metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startedMetadataProviderException
- throw is there is a problem process the cached metadataprotected void processNewMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes) throws MetadataProviderException
metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startedmetadataBytes
- raw bytes of the new metadata documentMetadataProviderException
- thrown if there is a problem unmarshalling or filtering the new metadataprotected void processPreExpiredMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes, XMLObject metadata)
AbstractMetadataProvider.isValid(XMLObject)
method.metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startedmetadataBytes
- raw bytes of the new metadata documentmetadata
- new metadata document unmarshalledprotected void processNonExpiredMetadata(String metadataIdentifier, org.joda.time.DateTime refreshStart, byte[] metadataBytes, XMLObject metadata) throws MetadataProviderException
AbstractMetadataProvider.isValid(XMLObject)
method.metadataIdentifier
- identifier of the metadata sourcerefreshStart
- when the current refresh cycle startedmetadataBytes
- raw bytes of the new metadata documentmetadata
- new metadata document unmarshalledMetadataProviderException
- thrown if there s a problem processing the metadataprotected void postProcessMetadata(byte[] metadataBytes, Document metadataDom, XMLObject metadata) throws MetadataProviderException
XMLObject
) but before the metadata is saved off. Any exception thrown by this hook will cause the
retrieved metadata to be discarded.
The default implementation of this method is a no-opmetadataBytes
- raw metadata bytes retrieved via fetchMetadata()
metadataDom
- metadata after it has been parsed in to a DOM documentmetadata
- metadata after it has been run through all registered filters and its DOM releasedMetadataProviderException
- thrown if there is a problem with the provided dataprotected long computeNextRefreshDelay(org.joda.time.DateTime expectedExpiration)
expectedExpiration
- the time when the metadata is expected to expire and need refreshingprotected byte[] inputstreamToByteArray(InputStream ins) throws MetadataProviderException
ins
- input stream to convertMetadataProviderException
- thrown if there is a problem reading the resultant byte arrayCopyright © 2012. All Rights Reserved.