Class DefaultLocalMediaFileCacheService
- java.lang.Object
-
- de.hybris.platform.media.storage.impl.DefaultLocalMediaFileCacheService
-
- All Implemented Interfaces:
LocalMediaFileCacheService
public class DefaultLocalMediaFileCacheService extends java.lang.Object implements LocalMediaFileCacheService
Default implementation of
LocalMediaFileCacheinterface. Allows to cache locally any stream and returns binary data asFileorFileInputStreamfrom local cache.To configure folder to use local cache use following property key:
folder.folderQualifier.local.cache = true
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultLocalMediaFileCacheService.MediaCacheFileInputStreamstatic classDefaultLocalMediaFileCacheService.MediaCacheKeystatic classDefaultLocalMediaFileCacheService.MediaCacheUnit-
Nested classes/interfaces inherited from interface de.hybris.platform.media.storage.LocalMediaFileCacheService
LocalMediaFileCacheService.StreamGetter
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCACHE_FILE_NAME_DELIM
-
Constructor Summary
Constructors Constructor Description DefaultLocalMediaFileCacheService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinit()Recreates cache and adds lifecycle callback after bean constructionvoidremoveFromCache(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)Removes given media from local cache.voidsetCacheController(CacheController cacheController)voidsetCacheRecreator(MediaCacheRecreator cacheRecreator)voidsetMainDataDir(java.io.File mainDataDir)voidsetMediaCacheRegion(MediaCacheRegion mediaCacheRegion)voidsetStorageConfigService(MediaStorageConfigService storageConfigService)voidsetStorageRegistry(MediaStorageRegistry storageRegistry)voidsetStorageStrategy(LocalFileMediaStorageStrategy storageStrategy)java.io.FilestoreOrGetAsFile(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location, LocalMediaFileCacheService.StreamGetter streamGetter)Checks whether there is local cached version of media data and stores it if not, then returns it as regularFiletaken from cache.java.io.InputStreamstoreOrGetAsStream(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location, LocalMediaFileCacheService.StreamGetter streamGetter)Checks whether there is local cached version of media data and stores it if not, then returns it asFileInputStreambuild on top of cached file.
-
-
-
Field Detail
-
CACHE_FILE_NAME_DELIM
public static final java.lang.String CACHE_FILE_NAME_DELIM
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
@PostConstruct public void init()
Recreates cache and adds lifecycle callback after bean construction
-
storeOrGetAsFile
public java.io.File storeOrGetAsFile(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location, LocalMediaFileCacheService.StreamGetter streamGetter)
Description copied from interface:LocalMediaFileCacheServiceChecks whether there is local cached version of media data and stores it if not, then returns it as regularFiletaken from cache.- Specified by:
storeOrGetAsFilein interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the locationstreamGetter- the stream getter which returns proper data stream for particularMediaitem.- Returns:
- the
Fileobject
-
storeOrGetAsStream
public java.io.InputStream storeOrGetAsStream(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location, LocalMediaFileCacheService.StreamGetter streamGetter)
Description copied from interface:LocalMediaFileCacheServiceChecks whether there is local cached version of media data and stores it if not, then returns it asFileInputStreambuild on top of cached file.- Specified by:
storeOrGetAsStreamin interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the locationstreamGetter- the stream getter which returns proper data stream for particularMediaitem.- Returns:
- the
FileInputStreamobject
-
removeFromCache
public void removeFromCache(MediaStorageConfigService.MediaFolderConfig config, java.lang.String location)
Description copied from interface:LocalMediaFileCacheServiceRemoves given media from local cache. This method is safe in terms of whenever some stream is already opened it will wait with removing cached file from disk until last client will close stream.- Specified by:
removeFromCachein interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the location of cached file in real storage
-
setMainDataDir
public void setMainDataDir(java.io.File mainDataDir)
-
setCacheController
public void setCacheController(CacheController cacheController)
-
setStorageRegistry
public void setStorageRegistry(MediaStorageRegistry storageRegistry)
-
setStorageStrategy
public void setStorageStrategy(LocalFileMediaStorageStrategy storageStrategy)
-
setMediaCacheRegion
public void setMediaCacheRegion(MediaCacheRegion mediaCacheRegion)
-
setStorageConfigService
public void setStorageConfigService(MediaStorageConfigService storageConfigService)
-
setCacheRecreator
public void setCacheRecreator(MediaCacheRecreator cacheRecreator)
-
-