Package org.zeroturnaround.javarebel
Interface ClassBytecodeProcessorCache
-
public interface ClassBytecodeProcessorCacheThis interface allowsclass bytecode processorsto 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; } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StringcomputeKey(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.voidput(String key, byte[] bytes)Stores given bytes associated with the given key.
-
-
-
Method Detail
-
computeKey
String computeKey(String className, byte[] bytecode, ClassBytecodeProcessor processor, String tag)
Computes the cache key for the given arguments.- Parameters:
className- the name of the processed classbytecode- the class bytes that are to be processedprocessor- the processortag- a custom tag to differentiate distinct processor configurations- Returns:
- a cache key, or
nullif the class loader is not cache capable
-
get
byte[] get(String key)
Returns the cached bytes corresponding to the given key.
-
put
void put(String key, byte[] bytes)
Stores given bytes associated with the given key.
-
-