Class DefaultFileLoadingStrategy

  • All Implemented Interfaces:
    LoadingStrategy

    @ThreadSafe
    public class DefaultFileLoadingStrategy
    extends Object
    implements LoadingStrategy
    Default strategy for loading information from a file.
    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • metadataFile

        @Nullable
        private final File metadataFile
        The metadata file.
      • metadataFileFriendlyName

        @Nonnull
        @NotEmpty
        private final String metadataFileFriendlyName
        The metadata file name to use in logs.
    • Constructor Detail

      • DefaultFileLoadingStrategy

        public DefaultFileLoadingStrategy​(@Nullable
                                          Resource metadata)
                                   throws IOException
        Constructor.
        Parameters:
        metadata - the metadata file resource. Can be null.
        Throws:
        IOException - if the file is not null put does not exist.
    • Method Detail

      • getMetadataUpdateTime

        private Instant getMetadataUpdateTime()
        Get the time for the last update/modification of the metadata file.
        Returns:
        The last update time.
      • load

        @Nullable
        public byte[] load​(@Nonnull
                           CacheLoadingContext context)
                    throws CacheLoadingException
        Description copied from interface: LoadingStrategy
        Load cache data from a source. If the source data has not changed from the last time it was loaded (as specified in the CacheLoadingContext) a null should be returned. If source data can not be loaded for a known and accepted reason, a null should be returned. For any other error in loading cache data, the CacheLoadingException should be thrown.
        Specified by:
        load in interface LoadingStrategy
        Parameters:
        context - the cache loading context
        Returns:
        the cache information as bytes.
        Throws:
        CacheLoadingException - if there is an error loading the cache.
      • getSourceIdentifier

        @Nonnull
        public String getSourceIdentifier()
        Description copied from interface: LoadingStrategy
        Get a friendly name source identifier to use in log statements.
        Specified by:
        getSourceIdentifier in interface LoadingStrategy
        Returns:
        the source identifier friendly name.