1 4 package com.tc.aspectwerkz.proxy; 5 6 import java.util.HashMap ; 7 import java.util.Map ; 8 9 14 public class ClassBytecodeRepository { 15 private static final byte[] EMPTY_BYTE_ARRAY = new byte[] {}; 17 18 private static final ClassBytecodeRepository soleInstance = new ClassBytecodeRepository(); 19 20 private final Map nameToBytecodeMap = new HashMap (); 22 23 public static void storeBytecode(final byte[] bytes, final String name) { 24 synchronized (soleInstance.nameToBytecodeMap) { 25 soleInstance.nameToBytecodeMap.put(name, bytes); 26 } 37 } 38 39 public static byte[] findBytecodeBy(final String name) { 40 synchronized (soleInstance.nameToBytecodeMap) { 41 Object bytesOrNull = soleInstance.nameToBytecodeMap.get(name); 42 if (bytesOrNull == null) { 43 return EMPTY_BYTE_ARRAY; 44 } else { 45 return (byte[]) bytesOrNull; 46 } 47 48 } 67 } 68 } 69 | Popular Tags |