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

public abstract Class AsynchronousFileCacheBacking

extends AbstractIndexedFileCacheBacking
Class Inheritance
Known Direct Subclasses
org.aspectj.weaver.tools.cache.FlatFileCacheBacking, org.aspectj.weaver.tools.cache.ZippedFileCacheBacking
Imports
java.io.File, java.util.ArrayList, .Collections, .List, .Map, java.util.concurrent.BlockingQueue, .ExecutorService, .Executors, .Future, .LinkedBlockingQueue, org.aspectj.util.FileUtil, .LangUtil, org.aspectj.weaver.tools.Trace, .TraceFactory

Uses a background thread to do the actual I/O and for caching "persistence" so that the caching works faster on repeated activations of the application. The class maintains an in-memory cache, and uses a queue of AsyncCommands to signal to a background thread various actions required to "synchronize" the in-memory cache with the persisted copy. Whenever there is a cache miss from the get(CachedClassReference, byte[]) call, the weaver issues a put(CachedClassEntry, byte[]) call. This call has 2 side-effects: The actual persistence is implemented by the concrete classes

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
public static interface
AsynchronousFileCacheBacking.AsyncCommand

Represents an asynchronous command that can be sent to the AsynchronousFileCacheBacking instance to be executed on it asynchronously

public static interface
public static class
public static class
public abstract static class
AsynchronousFileCacheBacking.KeyedCommand

Base class for AbstractCommands that refer to a cache key

public static class
public static class

Field Summary

Modifier and TypeField and Description
protected final Map<String, byte[]>
private static final BlockingQueue<AsynchronousFileCacheBacking.AsyncCommand>
private static Future<?>
private static final ExecutorService
protected final Map<String, byte[]>
protected final Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
protected final Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
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
public void
clear()

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

Clear the entire cache
protected static final <T extends AsynchronousFileCacheBacking> T
protected void
protected void
protected void
protected void
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
public Map<String, byte[]>
protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
public List<AbstractIndexedFileCacheBacking.IndexEntry>
public Map<String, AbstractIndexedFileCacheBacking.IndexEntry>
public static final boolean
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 abstract Map<String, byte[]>
public void
protected AbstractIndexedFileCacheBacking.IndexEntry
protected abstract void
removeClassBytes(String
The key representing the class whose bytes are to be removed
key
)

Helper for executeRemoveCommand(RemoveCommand)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.aspectj.weaver.tools.cache.AbstractIndexedFileCacheBacking:
createIndexEntrygetIndexFilegetKeysreadIndexreadIndexreadIndexresolveIndexMapEntrywriteIndexwriteIndexwriteIndexwriteIndexwriteIndex

Field Detail

bytesMapback to summary
protected final Map<String, byte[]> bytesMap
commandsQback to summary
private static final BlockingQueue<AsynchronousFileCacheBacking.AsyncCommand> commandsQ
commandsRunnerback to summary
private static Future<?> commandsRunner
execServiceback to summary
private static final ExecutorService execService
exposedBytesback to summary
protected final Map<String, byte[]> exposedBytes
exposedIndexback to summary
protected final Map<String, AbstractIndexedFileCacheBacking.IndexEntry> exposedIndex
indexback to summary
protected final Map<String, AbstractIndexedFileCacheBacking.IndexEntry> index

Constructor Detail

AsynchronousFileCacheBackingback to summary
protected AsynchronousFileCacheBacking(File cacheDir)

Method Detail

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
protected static final <T extends AsynchronousFileCacheBacking> T createBacking(File cacheDir, AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T> creator)
executeClearCommandback to summary
protected void executeClearCommand() throws Exception
executeCommandback to summary
protected void executeCommand(AsynchronousFileCacheBacking.AsyncCommand cmd) throws Exception
executeInsertCommandback to summary
protected void executeInsertCommand(AsynchronousFileCacheBacking.InsertCommand cmd) throws Exception
executeRemoveCommandback to summary
protected void executeRemoveCommand(AsynchronousFileCacheBacking.RemoveCommand cmd) throws Exception
executeUpdateIndexCommandback to summary
protected void executeUpdateIndexCommand() throws Exception
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

getBytesMapback to summary
public Map<String, byte[]> getBytesMap()
getIndexback to summary
protected Map<String, AbstractIndexedFileCacheBacking.IndexEntry> getIndex()

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

Annotations
@Override
getIndexEntriesback to summary
public List<AbstractIndexedFileCacheBacking.IndexEntry> getIndexEntries()
getIndexMapback to summary
public Map<String, AbstractIndexedFileCacheBacking.IndexEntry> getIndexMap()
postCacheCommandback to summary
public static final boolean postCacheCommand(AsynchronousFileCacheBacking.AsyncCommand cmd)
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

readClassBytesback to summary
protected abstract Map<String, byte[]> readClassBytes(Map<String, AbstractIndexedFileCacheBacking.IndexEntry> indexMap, File cacheDir)
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

removeback to summary
protected AbstractIndexedFileCacheBacking.IndexEntry remove(String key)
removeClassBytesback to summary
protected abstract void removeClassBytes(String key) throws Exception

Helper for executeRemoveCommand(RemoveCommand)

Parameters
key:String

The key representing the class whose bytes are to be removed

Exceptions
Exception:
if failed to remove class bytes
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.aspectj.weaver.tools.cache back to summary

public abstract Class AsynchronousFileCacheBacking.AbstractCommand

extends Object
implements AsyncCommand
Class Inheritance
  • java.lang.Object
  • org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand
All Implemented Interfaces
org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AsyncCommand
Known Direct Subclasses
org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.ClearCommand, org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.UpdateIndexCommand, org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.KeyedCommand

Field Summary

Modifier and TypeField and Description
private final AsynchronousFileCacheBacking

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final AsynchronousFileCacheBacking
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cacheback to summary
private final AsynchronousFileCacheBacking cache

Constructor Detail

AbstractCommandback to summary
protected AbstractCommand(AsynchronousFileCacheBacking backing)

Method Detail

getCacheback to summary
public final AsynchronousFileCacheBacking getCache()

Implements org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AsyncCommand.getCache.

Returns:AsynchronousFileCacheBacking

Doc from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AsyncCommand.getCache.

The AsynchronousFileCacheBacking on which this command is supposed to be executed

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.aspectj.weaver.tools.cache back to summary

public Interface AsynchronousFileCacheBacking.AsyncCommand

Known Direct Implementers
org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand

Represents an asynchronous command that can be sent to the AsynchronousFileCacheBacking instance to be executed on it asynchronously

Method Summary

Modifier and TypeMethod and Description
public AsynchronousFileCacheBacking

Returns:

The AsynchronousFileCacheBacking on which this command is supposed to be executed
getCache
()

Method Detail

getCacheback to summary
public AsynchronousFileCacheBacking getCache()
Returns:AsynchronousFileCacheBacking

The AsynchronousFileCacheBacking on which this command is supposed to be executed

See Also
AsynchronousFileCacheBacking#executeCommand(AsyncCommand)
org.aspectj.weaver.tools.cache back to summary

public Interface AsynchronousFileCacheBacking.AsynchronousFileCacheBackingCreator<T extends org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking>


Method Summary

Modifier and TypeMethod and Description
public T
create(File cacheDir)

Method Detail

createback to summary
public T create(File cacheDir)
org.aspectj.weaver.tools.cache back to summary

public Class AsynchronousFileCacheBacking.ClearCommand

extends AbstractCommand
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand:
getCachetoString

Constructor Detail

ClearCommandback to summary
public ClearCommand(AsynchronousFileCacheBacking cache)
org.aspectj.weaver.tools.cache back to summary

public Class AsynchronousFileCacheBacking.InsertCommand

extends KeyedCommand
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]

Constructor Summary

AccessConstructor and Description
public
InsertCommand(AsynchronousFileCacheBacking cache, String keyValue, byte[] classBytes)

Method Summary

Modifier and TypeMethod and Description
public final byte[]
Inherited from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.KeyedCommand:
getKeytoString

Field Detail

bytesback to summary
private final byte[] bytes

Constructor Detail

InsertCommandback to summary
public InsertCommand(AsynchronousFileCacheBacking cache, String keyValue, byte[] classBytes)

Method Detail

getClassBytesback to summary
public final byte[] getClassBytes()
org.aspectj.weaver.tools.cache back to summary

public abstract Class AsynchronousFileCacheBacking.KeyedCommand

extends AbstractCommand
Class Inheritance
Known Direct Subclasses
org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.RemoveCommand, org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.InsertCommand

Base class for AbstractCommands that refer to a cache key

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final String
public String
Inherited from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand:
getCache

Field Detail

keyback to summary
private final String key

Constructor Detail

KeyedCommandback to summary
protected KeyedCommand(AsynchronousFileCacheBacking cache, String keyValue)

Method Detail

getKeyback to summary
public final String getKey()
toStringback to summary
public String toString()

Overrides org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.aspectj.weaver.tools.cache back to summary

public Class AsynchronousFileCacheBacking.RemoveCommand

extends KeyedCommand
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.KeyedCommand:
getKeytoString

Constructor Detail

RemoveCommandback to summary
public RemoveCommand(AsynchronousFileCacheBacking cache, String keyValue)
org.aspectj.weaver.tools.cache back to summary

public Class AsynchronousFileCacheBacking.UpdateIndexCommand

extends AbstractCommand
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.aspectj.weaver.tools.cache.AsynchronousFileCacheBacking.AbstractCommand:
getCachetoString

Constructor Detail

UpdateIndexCommandback to summary
public UpdateIndexCommand(AsynchronousFileCacheBacking cache)