org.aspectj.weaver.tools.cache
Class ZippedFileCacheBacking

java.lang.Object
  extended by org.aspectj.weaver.tools.cache.AbstractCacheBacking
      extended by org.aspectj.weaver.tools.cache.AbstractFileCacheBacking
          extended by org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking
              extended by org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking
                  extended by org.aspectj.weaver.tools.cache.ZippedFileCacheBacking
All Implemented Interfaces:
CacheBacking

public class ZippedFileCacheBacking
extends AsynchronousFileCacheBacking

Uses a ZIP file to store the instrumented classes/aspects - each one as a separate ZipEntry. This mechanism is suitable for relatively large numbers of instrumented classes/aspects (100's and more) since it holds all of them in a single (ZIP) file. The down side is that any modifications to the cache require re-writing the entire ZIP file. This can cause the ZIP file to become corrupted if interrupted in mid-update, thus requiring the re-population of the cache on next application activation (though the overhead in this case is not prohibitvely high...)


Nested Class Summary
 
Nested classes/interfaces inherited from class org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking
AsynchronousFileCacheBacking.AbstractCommand, AsynchronousFileCacheBacking.AsyncCommand, AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T extends AsynchronousFileCacheBacking>, AsynchronousFileCacheBacking.ClearCommand, AsynchronousFileCacheBacking.InsertCommand, AsynchronousFileCacheBacking.KeyedCommand, AsynchronousFileCacheBacking.RemoveCommand, AsynchronousFileCacheBacking.UpdateIndexCommand
 
Nested classes/interfaces inherited from class org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking
AbstractIndexedFileCacheBacking.IndexEntry
 
Field Summary
static java.lang.String ZIP_FILE
           
 
Fields inherited from class org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking
bytesMap, exposedBytes, exposedIndex, index
 
Fields inherited from class org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking
EMPTY_INDEX, EMPTY_KEYS, INDEX_FILE
 
Fields inherited from class org.aspectj.weaver.tools.cache.AbstractFileCacheBacking
WEAVED_CLASS_CACHE_DIR
 
Fields inherited from class org.aspectj.weaver.tools.cache.AbstractCacheBacking
logger
 
Constructor Summary
ZippedFileCacheBacking(java.io.File cacheDir)
           
 
Method Summary
static ZippedFileCacheBacking createBacking(java.io.File cacheDir)
           
 java.io.File getZipFile()
           
protected  java.util.Map<java.lang.String,byte[]> readClassBytes(java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap, java.io.File cacheDir)
           
static java.util.Map<java.lang.String,byte[]> readZipClassBytes(java.io.File file)
           
protected  void removeClassBytes(java.lang.String key)
          Helper for AsynchronousFileCacheBacking.executeRemoveCommand(RemoveCommand)
protected  AbstractIndexedFileCacheBacking.IndexEntry resolveIndexMapEntry(java.io.File cacheDir, AbstractIndexedFileCacheBacking.IndexEntry ie)
           
protected  boolean syncClassBytesEntries(java.io.File dataFile, java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap, java.util.Map<java.lang.String,byte[]> entriesMap)
           
protected  java.util.Collection<java.lang.String> syncIndexEntries(java.io.File dataFile, java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap, java.util.Map<java.lang.String,byte[]> entriesMap)
           
protected  void writeClassBytes(java.lang.String key, byte[] bytes)
           
static void writeZipClassBytes(java.io.File file, java.util.Map<java.lang.String,byte[]> entriesMap)
           
 
Methods inherited from class org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking
clear, createBacking, executeClearCommand, executeCommand, executeInsertCommand, executeRemoveCommand, executeUpdateIndexCommand, get, getBytesMap, getIndex, getIndexEntries, getIndexMap, postCacheCommand, put, remove, remove, toString
 
Methods inherited from class org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking
createIndexEntry, getIndexFile, getKeys, readIndex, readIndex, readIndex, writeIndex, writeIndex, writeIndex, writeIndex, writeIndex
 
Methods inherited from class org.aspectj.weaver.tools.cache.AbstractFileCacheBacking
close, close, delete, getCacheDirectory
 
Methods inherited from class org.aspectj.weaver.tools.cache.AbstractCacheBacking
crc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ZIP_FILE

public static final java.lang.String ZIP_FILE
See Also:
Constant Field Values
Constructor Detail

ZippedFileCacheBacking

public ZippedFileCacheBacking(java.io.File cacheDir)
Method Detail

getZipFile

public java.io.File getZipFile()

createBacking

public static final ZippedFileCacheBacking createBacking(java.io.File cacheDir)

writeClassBytes

protected void writeClassBytes(java.lang.String key,
                               byte[] bytes)
                        throws java.lang.Exception
Overrides:
writeClassBytes in class AbstractFileCacheBacking
Throws:
java.lang.Exception

removeClassBytes

protected void removeClassBytes(java.lang.String key)
                         throws java.lang.Exception
Description copied from class: AsynchronousFileCacheBacking
Helper for AsynchronousFileCacheBacking.executeRemoveCommand(RemoveCommand)

Specified by:
removeClassBytes in class AsynchronousFileCacheBacking
Parameters:
key - The key representing the class whose bytes are to be removed
Throws:
java.lang.Exception - if failed to remove class bytes

readClassBytes

protected java.util.Map<java.lang.String,byte[]> readClassBytes(java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap,
                                                                java.io.File cacheDir)
Specified by:
readClassBytes in class AsynchronousFileCacheBacking

syncIndexEntries

protected java.util.Collection<java.lang.String> syncIndexEntries(java.io.File dataFile,
                                                                  java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap,
                                                                  java.util.Map<java.lang.String,byte[]> entriesMap)

syncClassBytesEntries

protected boolean syncClassBytesEntries(java.io.File dataFile,
                                        java.util.Map<java.lang.String,AbstractIndexedFileCacheBacking.IndexEntry> indexMap,
                                        java.util.Map<java.lang.String,byte[]> entriesMap)

resolveIndexMapEntry

protected AbstractIndexedFileCacheBacking.IndexEntry resolveIndexMapEntry(java.io.File cacheDir,
                                                                          AbstractIndexedFileCacheBacking.IndexEntry ie)
Overrides:
resolveIndexMapEntry in class AbstractIndexedFileCacheBacking

readZipClassBytes

public static final java.util.Map<java.lang.String,byte[]> readZipClassBytes(java.io.File file)
                                                                      throws java.io.IOException
Throws:
java.io.IOException

writeZipClassBytes

public static final void writeZipClassBytes(java.io.File file,
                                            java.util.Map<java.lang.String,byte[]> entriesMap)
                                     throws java.io.IOException
Throws:
java.io.IOException