Top Description Fields Constructors Methods
org.aspectj.weaver.tools.cache

public Class DefaultFileCacheBacking

extends AbstractIndexedFileCacheBacking
Class Inheritance
Imports
java.io.File, .FileInputStream, .FileOutputStream, .FilenameFilter, .OutputStream, java.util.Map, org.aspectj.bridge.MessageUtil, org.aspectj.util.FileUtil, .LangUtil

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.

Field Summary

Modifier and TypeField and Description
private final Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
private static final Object
Inherited from org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking:
EMPTY_INDEXEMPTY_KEYSINDEX_FILE

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
public void
clear()

Implements org.aspectj.weaver.tools.cache.CacheBacking.clear.

Clear the entire cache
public static final DefaultFileCacheBacking
createBacking(File cacheDir)

public static CacheBacking
protected void
public CachedClassEntry
get(CachedClassReference
entry to retrieve
ref
,
byte[]
Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class
originalBytes
)

Implements org.aspectj.weaver.tools.cache.CacheBacking.get.

Get a cache entry
protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
public String[]
getKeys(final String regex)

Overrides org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.getKeys.

Implements org.aspectj.weaver.tools.cache.CacheBacking.getKeys.

Return a list of keys which match the given regex.
public void
put(CachedClassEntry
key of the entry
entry
,
byte[]
Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class
originalBytes
)

Implements org.aspectj.weaver.tools.cache.CacheBacking.put.

Put an entry in the cache
protected byte[]
read(File file, long expectedCRC)

protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
public void
private void
protected AbstractIndexedFileCacheBacking.IndexEntry
protected long
write(File file, byte[] bytes)

protected void
Inherited from org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking:
createIndexEntrygetIndexFilereadIndexreadIndexwriteIndexwriteIndexwriteIndexwriteIndex

Field Detail

indexback to summary
private final Map<String, AbstractIndexedFileCacheBacking.IndexEntry> index
LOCKback to summary
private static final Object LOCK

Constructor Detail

DefaultFileCacheBackingback to summary
protected DefaultFileCacheBacking(File cacheDir)

Method Detail

addIndexEntryback to summary
private void addIndexEntry(AbstractIndexedFileCacheBacking.IndexEntry ie)
clearback to summary
public void clear()

Implements org.aspectj.weaver.tools.cache.CacheBacking.clear.

Doc from org.aspectj.weaver.tools.cache.CacheBacking.clear.

Clear the entire cache

createBackingback to summary
public static final DefaultFileCacheBacking createBacking(File cacheDir)
createBackingback to summary
public static CacheBacking createBacking(String scope)
deleteback to summary
protected void delete(File file)

Overrides org.aspectj.weaver.tools.cache.AbstractFileCacheBacking.delete.

Annotations
@Override
getback to summary
public CachedClassEntry get(CachedClassReference ref, byte[] originalBytes)

Implements org.aspectj.weaver.tools.cache.CacheBacking.get.

Doc from org.aspectj.weaver.tools.cache.CacheBacking.get.

Get a cache entry

Parameters
ref:CachedClassReference

entry to retrieve

originalBytes:byte[]

Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class

Returns:CachedClassEntry

the cached bytes or null, if the entry does not exist

getIndexback to summary
protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> getIndex()

Implements abstract org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.getIndex.

Annotations
@Override
getKeysback to summary
public String[] getKeys(final String regex)

Overrides org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.getKeys.

Implements org.aspectj.weaver.tools.cache.CacheBacking.getKeys.

Doc from org.aspectj.weaver.tools.cache.CacheBacking.getKeys.

Return a list of keys which match the given regex.

Annotations
@Override
putback to summary
public void put(CachedClassEntry entry, byte[] originalBytes)

Implements org.aspectj.weaver.tools.cache.CacheBacking.put.

Doc from org.aspectj.weaver.tools.cache.CacheBacking.put.

Put an entry in the cache

Parameters
entry:CachedClassEntry

key of the entry

originalBytes:byte[]

Pre-weaving class bytes - required in order to ensure that the cached entry refers to the same original class

readback to summary
protected byte[] read(File file, long expectedCRC)
readIndexback to summary
protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> readIndex()

Overrides org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.readIndex.

Annotations
@Override
removeback to summary
public void remove(CachedClassReference ref)

Implements org.aspectj.weaver.tools.cache.CacheBacking.remove.

Doc from org.aspectj.weaver.tools.cache.CacheBacking.remove.

Remove an entry from the cache

removeIndexEntryback to summary
private void removeIndexEntry(String key)
resolveIndexMapEntryback to summary
protected AbstractIndexedFileCacheBacking.IndexEntry resolveIndexMapEntry(File cacheDir, AbstractIndexedFileCacheBacking.IndexEntry ie)

Overrides org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.resolveIndexMapEntry.

Annotations
@Override
writeback to summary
protected long write(File file, byte[] bytes)
writeIndexback to summary
protected void writeIndex()

Overrides org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking.writeIndex.

Annotations
@Override