public interface ClassBytecodeProcessorCache
class bytecode processors to cache their transformations between
runs. A typical usage will look something like this:
public class MyCBP implements ClassBytecodeProcessor {
public byte[] process(ClassLoader cl, String classname, byte[] bytecode) {
ClassBytecodeProcessorCache cache = IntegrationFactory.getInstance().getClassBytecodeProcessorCache();
String key = cache.computeKey(cl, classname, bytecode, null);
if (key != null) {
byte[] cachedBytes = cache.get(key);
if (cachedBytes != null)
return cachedBytes;
}
// ... do actual processing ...
if (key != null)
cache.put(key, processedBytes);
return processedBytes;
}
}
| Modifier and Type | Method and Description |
|---|---|
String |
computeKey(String className,
byte[] bytecode,
ClassBytecodeProcessor processor,
String tag)
Computes the cache key for the given arguments.
|
byte[] |
get(String key)
Returns the cached bytes corresponding to the given key.
|
void |
put(String key,
byte[] bytes)
Stores given bytes associated with the given key.
|
String computeKey(String className, byte[] bytecode, ClassBytecodeProcessor processor, String tag)
className - the name of the processed classbytecode - the class bytes that are to be processedprocessor - the processortag - a custom tag to differentiate distinct processor configurationsnull if the class loader is not cache capablebyte[] get(String key)
void put(String key, byte[] bytes)
Copyright © 2019. All rights reserved.