public class HashCache extends AbstractLogEnabled implements Component, Serviceable
Modifier and Type | Class and Description |
---|---|
static class |
HashCache.FileData
The description of a file
|
Modifier and Type | Field and Description |
---|---|
private static Pattern |
__EXTERNAL_URL |
private static Pattern |
__IMPORT_WITHOUT_MEDIA_PATTERN |
private Map<String,List<String>> |
_dependenciesCache |
private Map<String,Long> |
_dependenciesCacheValidity |
private Map<String,List<HashCache.FileData>> |
_hashCache
Hash cache
Key if file url
|
private SourceResolver |
_sourceResolver |
static String |
ROLE
The avalon ROLE
|
Constructor and Description |
---|
HashCache() |
Modifier and Type | Method and Description |
---|---|
private List<HashCache.FileData> |
_getCssFileDependencies(String uri,
Source cssSource,
String tag) |
private Set<HashCache.FileData> |
_getFileDependencies(String cssUri,
String media,
String tag,
boolean firstLevel) |
String |
createHash(Map<String,Map<String,String>> files,
String salt)
Creates and memorize a hash code corresponding to a list of files
|
List<HashCache.FileData> |
getFilesForHash(String hash,
boolean firstLevel)
Get the file list corresponding to the given hashcode
|
void |
service(ServiceManager manager) |
getLogger, setLogger
private static final Pattern __IMPORT_WITHOUT_MEDIA_PATTERN
private static final Pattern __EXTERNAL_URL
private Map<String,List<HashCache.FileData>> _hashCache
private Map<String,Long> _dependenciesCacheValidity
private Map<String,List<String>> _dependenciesCache
private SourceResolver _sourceResolver
public HashCache()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public List<HashCache.FileData> getFilesForHash(String hash, boolean firstLevel)
hash
- The hashcode created by createHash in this sessionfirstLevel
- File imported by other files will not be includedpublic String createHash(Map<String,Map<String,String>> files, String salt) throws IllegalArgumentException
files
- The files. Key is the file uri and the value is a map with two keys 'media' and 'tag'.salt
- Additional parameter used as salt for the hash key.IllegalArgumentException
- If an error occurredprivate Set<HashCache.FileData> _getFileDependencies(String cssUri, String media, String tag, boolean firstLevel) throws IllegalArgumentException
IllegalArgumentException
private List<HashCache.FileData> _getCssFileDependencies(String uri, Source cssSource, String tag) throws IllegalArgumentException
IllegalArgumentException