Class DefaultFileCacheBacking
java.lang.Object
org.aspectj.weaver.tools.cache.AbstractCacheBacking
org.aspectj.weaver.tools.cache.AbstractFileCacheBacking
org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking
org.aspectj.weaver.tools.cache.DefaultFileCacheBacking
- All Implemented Interfaces:
CacheBacking
Naive File-Backed Class Cache with no expiry or application
centric invalidation.
Enabled with the system property, "aj.weaving.cache.dir" If this system property is not set, no caching will be performed.
A CRC checksum is stored alongside the class file to verify the bytes on read. If for some reason there is an error reading either the class or crc file, or if the crc does not match the class data the cache entry is deleted.
An alternate implementation of this could store the class file as a jar/zip directly, which would have the required crc; as a first pass however it is somewhat useful to view these files in expanded form for debugging.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractIndexedFileCacheBacking
AbstractIndexedFileCacheBacking.IndexEntryModifier and TypeClassDescriptionstatic classThe default index entry in the index file -
Field Summary
Fields inherited from class AbstractIndexedFileCacheBacking
EMPTY_INDEX, EMPTY_KEYS, INDEX_FILEModifier and TypeFieldDescriptionprotected static final AbstractIndexedFileCacheBacking.IndexEntry[]protected static final String[]static final StringDefault name of cache index file - assumed to containAbstractIndexedFileCacheBacking.IndexEntry-sFields inherited from class AbstractFileCacheBacking
WEAVED_CLASS_CACHE_DIRModifier and TypeFieldDescriptionstatic final StringDefault property used to specify a default weaving cache dir locationFields inherited from class AbstractCacheBacking
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the entire cachestatic final DefaultFileCacheBackingcreateBacking(File cacheDir) static CacheBackingcreateBacking(String scope) protected voidget(CachedClassReference ref, byte[] originalBytes) Get a cache entryprotected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> getIndex()String[]Return a list of keys which match the given regex.voidput(CachedClassEntry entry, byte[] originalBytes) Put an entry in the cacheprotected byte[]protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> voidRemove an entry from the cacheprotected longprotected voidMethods inherited from class AbstractIndexedFileCacheBacking
createIndexEntry, getIndexFile, readIndex, readIndex, writeIndex, writeIndex, writeIndex, writeIndexModifier and TypeMethodDescriptionstatic final AbstractIndexedFileCacheBacking.IndexEntrycreateIndexEntry(CachedClassEntry classEntry, byte[] originalBytes) protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> protected voidwriteIndex(File file) protected voidwriteIndex(File indexFile, Collection<? extends AbstractIndexedFileCacheBacking.IndexEntry> entries) protected voidwriteIndex(File indexFile, Map<String, ? extends AbstractIndexedFileCacheBacking.IndexEntry> index) protected voidwriteIndex(File indexFile, AbstractIndexedFileCacheBacking.IndexEntry... entries) Methods inherited from class AbstractFileCacheBacking
close, close, getCacheDirectory, writeClassBytesModifier and TypeMethodDescriptionprotected voidclose(InputStream in, File file) protected voidclose(OutputStream out, File file) protected voidwriteClassBytes(String key, byte[] bytes) Methods inherited from class AbstractCacheBacking
crcModifier and TypeMethodDescriptionstatic final longcrc(byte[] bytes) Calculates CRC32 on the provided bytes
-
Constructor Details
-
DefaultFileCacheBacking
-
-
Method Details
-
createBacking
-
getIndex
- Specified by:
getIndexin classAbstractIndexedFileCacheBacking
-
resolveIndexMapEntry
protected AbstractIndexedFileCacheBacking.IndexEntry resolveIndexMapEntry(File cacheDir, AbstractIndexedFileCacheBacking.IndexEntry ie) - Overrides:
resolveIndexMapEntryin classAbstractIndexedFileCacheBacking
-
readIndex
- Overrides:
readIndexin classAbstractIndexedFileCacheBacking
-
writeIndex
protected void writeIndex()- Overrides:
writeIndexin classAbstractIndexedFileCacheBacking
-
clear
-
createBacking
-
getKeys
Description copied from interface:CacheBackingReturn a list of keys which match the given regex.- Specified by:
getKeysin interfaceCacheBacking- Overrides:
getKeysin classAbstractIndexedFileCacheBacking- Parameters:
regex-- Returns:
-
get
Description copied from interface:CacheBackingGet a cache entry- Parameters:
ref- entry to retrieveoriginalBytes- Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class- Returns:
- the cached bytes or null, if the entry does not exist
-
put
Description copied from interface:CacheBackingPut an entry in the cache- Parameters:
entry- key of the entryoriginalBytes- Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class
-
remove
-
delete
- Overrides:
deletein classAbstractFileCacheBacking
-
read
-
write
-