00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.util;
00032
00033 import java.util.Hashtable;
00034 import java.util.Map;
00035
00036 import org.apache.log4j.Logger;
00037 import org.objectweb.proactive.core.runtime.ProActiveRuntimeImpl;
00038 import org.objectweb.proactive.core.util.log.Loggers;
00039 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00040
00041
00050 public class ClassDataCache {
00051 static Logger logger = ProActiveLogger.getLogger(Loggers.CLASSLOADING);
00052 private static ClassDataCache classCache = null;
00053 private static Map<String, byte[]> classStorage;
00054
00055 private ClassDataCache() {
00056 classStorage = new Hashtable<String, byte[]>();
00057 }
00058
00059 public static ClassDataCache instance() {
00060 if (classCache == null) {
00061 return classCache = new ClassDataCache();
00062 } else {
00063 return classCache;
00064 }
00065 }
00066
00072 public boolean contains(String className) {
00073 return classStorage.containsKey(className);
00074 }
00075
00081 public void addClassData(String fullname, byte[] classData) {
00082 if (logger.isDebugEnabled()) {
00083 logger.debug(ProActiveRuntimeImpl.getProActiveRuntime().getURL() +
00084 " --> " + ("ClassDataCache caching class " + fullname));
00085 }
00086 classStorage.put(fullname, classData);
00087 }
00088
00093 public byte[] getClassData(String fullname) {
00094 if (logger.isDebugEnabled()) {
00095 logger.debug(ProActiveRuntimeImpl.getProActiveRuntime().getURL() +
00096 " --> " + ("ClassDataCache was asked for class " + fullname));
00097 }
00098 return classStorage.get(fullname);
00099 }
00100 }