Interface ClassBytecodeProcessorCache


public interface ClassBytecodeProcessorCache
This interface allows 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;
     }
   }
 
  • Method Summary

    Modifier and Type
    Method
    Description
    computeKey(String className, byte[] bytecode, ClassBytecodeProcessor processor, String tag)
    Computes the cache key for the given arguments.
    byte[]
    get(String key)
     
    void
    put(String key, byte[] bytes)
    Stores given bytes associated with the given key.
  • Method Details

    • 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 class
      bytecode - the class bytes that are to be processed
      processor - the processor
      tag - a custom tag to differentiate distinct processor configurations
      Returns:
      a cache key, or null if the class loader is not cache capable
    • get

      byte[] get(String key)
      Parameters:
      key - the 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.
      Parameters:
      key - the key
      bytes - the bytes to cache