/** Enable local caching of resolved proxy classes. This can only be used * if there is a single ULR and no redeployment of the proxy classes. * * @param flag true to enable caching, false to disable it */ public static void useClassCache(boolean flag) { if( flag == true ) classCache = new WeakValueHashMap(); else classCache = null; }
public static Class<?> getProxyClass(GUID guid) { synchronized (proxyCache) { return proxyCache.get(guid); } }
/** Clear the current proxy cache. * */ public static void flushClassCache() { classCache.clear(); }
public static Proxy createInterfaceProxy(ClassLoader loader, Class<?>[] interfaces, ProxyMixin[] mixins, InstanceAdvisor advisor) throws Exception { Class<?> clazz = createProxyClass(loader, mixins, interfaces); Proxy instance = (Proxy) clazz.newInstance(); instance.instanceAdvisor = advisor; instance.mixins = mixins; instance.interfaces = interfaces; instance.guid = new GUID(); synchronized (proxyCache) { proxyCache.put(instance.guid, clazz); } return instance; }
/** * @param identifier * @return true if item with given identifier is pooled * @throws RepositoryException */ boolean contains(String identifier) { return items.containsKey(identifier); }
public static GUID generateProxyClass(ClassLoader loader, ProxyMixin[] mixins, Class<?>[] interfaces) throws Exception { Class<?> clazz = createProxyClass(loader, mixins, interfaces); GUID guid = new GUID(); synchronized (proxyCache) { proxyCache.put(guid, clazz); } return guid; }
ItemReferencePool() { items = new WeakValueHashMap<String, ItemImpl>(); }
/** * Get ItemImpl from the pool using given data. * * @param newData ItemData * @param parent nodeData * @return ItemImpl item * @throws RepositoryException */ ItemImpl get(final ItemData newData, final NodeData parent) throws RepositoryException { final String identifier = newData.getIdentifier(); ItemImpl item = items.get(identifier); if (item != null) { item.loadData(newData, parent); } else { item = itemFactory.createItem(newData, parent); items.put(item.getInternalIdentifier(), item); } return item; }
protected void addSubDomainByName(Domain domain) { initSubDomainsByNameMap(); subDomainsByName.put(domain.getDomainName(), domain); }
private AspectManager findManagerByNameInternal(String name) { return subDomainsByName.get(name); }
protected void initSubDomainsByNameMap() { if (subDomainsByName == UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP) { synchronized(lazyCollectionLock) { if (subDomainsByName == UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP) { subDomainsByName = new WeakValueHashMap<String, Domain>(); } } } }
public static Proxy createInterfaceProxy(GUID guid, ClassLoader loader, Class<?>[] interfaces, ProxyMixin[] mixins, InstanceAdvisor advisor) throws Exception { Class<?> clazz = getProxyClass(guid); boolean wasFound = true; if (clazz == null) { wasFound = false; clazz = createProxyClass(loader, mixins, interfaces); } Proxy instance = (Proxy) clazz.newInstance(); instance.instanceAdvisor = advisor; instance.mixins = mixins; instance.interfaces = interfaces; instance.guid = guid; if (!wasFound) { synchronized (proxyCache) { proxyCache.put(guid, clazz); } } return instance; }
public static HashMap<Long, MethodPersistentReference> getMethodMap(String classname) { synchronized (maplock) { Class<?> clazz = classnameMap.get(classname); if (clazz == null) return null; return (HashMap<Long, MethodPersistentReference>) methodMapCache.get(clazz); } }
/** * Get the cache for the classloader * * @param cl the classloader * @return the map */ protected Map<String, T> getClassLoaderCache(ClassLoader cl) { synchronized (cache) { Map<String, T> result = cache.get(cl); if (result == null) { result = new WeakValueHashMap<String, T>(); cache.put(cl, result); } return result; } } }
classnameMap.put(clazz.getName(), proxyClass); proxiesForLoader.put(clazz, new WeakReference<Class<?>>(proxyClass)); HashMap<Long, MethodPersistentReference> map = methodMap(clazz);
ItemImpl reload(String identifier, ItemData newItemData) throws RepositoryException { ItemImpl item = items.get(identifier); if (item != null) { item.loadData(newItemData); return item; } return null; }
cache = new WeakValueHashMap(); compositeDataMethodCache.put(clazz, cache);
cache = new WeakValueHashMap(); compositeDataMethodCache.put(clazz, cache);