List of usage examples for java.util WeakHashMap WeakHashMap
public WeakHashMap()
From source file:WeakHashSet.java
/** * Constructs a new empty WeakHashSet with default values passed the the backing * store.//from w ww . ja va 2 s. c o m * * @see java.util.WeakHashMap#WeakHashMap() */ public WeakHashSet() { backingStore = new WeakHashMap(); }
From source file:org.xchain.framework.scanner.ScannerLifecycle.java
public ScannerLifecycle() { protocolMap.put("file", new FileProtocolScanner()); protocolMap.put("jar", new JarProtocolScanner()); // define the vfszip, vfsfile, and vfsmemory protocols if the jboss virtual file system classes are on the classpath. if (isVfsDefined()) { protocolMap.put("vfszip", new VfsProtocolScanner()); protocolMap.put("vfsfile", new VfsProtocolScanner()); protocolMap.put("vfsmemory", new VfsProtocolScanner()); }/*w w w . j a v a2 s. com*/ if (isZipDefined()) { protocolMap.put("zip", new ZipProtocolScanner()); } if (isBundleDefined()) { protocolMap.put("bundle", new BundleProtocolScanner()); protocolMap.put("bundleresource", new BundleProtocolScanner()); } if (MEMOIZE_SCAN_NODE) { cache = Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<RootUrlLocator, ScanNode>>()); } }
From source file:org.xflatdb.xflat.db.ConvertingTable.java
ConvertingTable(Class<T> type, String name) { super(name);//from ww w. ja va2 s . co m this.tableType = type; this.accessor = IdAccessor.forClass(type); if (!this.accessor.hasId()) { //we need to keep a reference to the ID in a weak cache idMap = Collections.synchronizedMap(new WeakHashMap<T, String>()); } else { idMap = null; } }
From source file:org.omnaest.utils.structure.map.decorator.CaseinsensitiveMapDecorator.java
/** * @see CaseinsensitiveMapDecorator//from w w w . ja v a 2 s.c o m * @param map * @param useCacheForKeys */ public CaseinsensitiveMapDecorator(Map<String, V> map, boolean useCacheForKeys) { super(map); this.sourceKeyToTargetKeyTranslationMap = useCacheForKeys ? MapUtils.lockedByReentrantLock(new WeakHashMap<String, String>()) : null; }
From source file:org.apache.ambari.server.orm.dao.ConfigGroupHostMappingDAO.java
private void populateCache() { if (!cacheLoaded) { gl.writeLock().lock();/*from w w w .ja v a2 s . c o m*/ try { if (configGroupHostMappingByHost == null) { configGroupHostMappingByHost = new WeakHashMap<String, Set<ConfigGroupHostMapping>>(); TypedQuery<ConfigGroupHostMappingEntity> query = entityManagerProvider.get().createQuery( "SELECT entity FROM ConfigGroupHostMappingEntity entity", ConfigGroupHostMappingEntity.class); List<ConfigGroupHostMappingEntity> configGroupHostMappingEntities = daoUtils.selectList(query); for (ConfigGroupHostMappingEntity configGroupHostMappingEntity : configGroupHostMappingEntities) { Set<ConfigGroupHostMapping> setByHost = configGroupHostMappingByHost .get((configGroupHostMappingEntity.getHostname())); if (setByHost == null) { setByHost = new HashSet<ConfigGroupHostMapping>(); configGroupHostMappingByHost.put(configGroupHostMappingEntity.getHostname(), setByHost); } ConfigGroupHostMapping configGroupHostMapping = buildConfigGroupHostMapping( configGroupHostMappingEntity); setByHost.add(configGroupHostMapping); } } } finally { gl.writeLock().unlock(); } cacheLoaded = true; } }
From source file:org.grouplens.grapht.InjectionContainer.java
private InjectionContainer(CachePolicy dft, LifecycleManager mgr) { defaultCachePolicy = dft;/*from w ww. ja v a2s.c o m*/ providerCache = new WeakHashMap<DAGNode<Component, Dependency>, Instantiator>(); manager = mgr; }
From source file:com.emc.ecs.sync.filter.GladinetMappingFilter.java
public GladinetMappingFilter() { dirCache = Collections.synchronizedMap(new WeakHashMap<String, String>()); idCache = Collections.synchronizedMap(new WeakHashMap<String, ObjectId>()); random = new Random(); baseDir = ""; }
From source file:org.kepler.gui.ViewManager.java
/** * Constructor.//from ww w. ja v a 2 s.c o m */ public ViewManager() { _viewPanes = new Vector<ViewPane>(); _viewAreas = new WeakHashMap<TableauFrame, JPanel>(); _viewComboBoxes = new WeakHashMap<TableauFrame, JComboBox>(); }
From source file:org.nabucco.alfresco.enhScriptEnv.common.script.batch.DefaultFacadeFactory.java
/** * {@inheritDoc}/* w w w.ja va 2s. co m*/ */ @Override public Scriptable toFacadedObject(final Scriptable obj, final Scriptable referenceScope, final String accessName) { final Scriptable facadedObject; if (obj != null && !(obj instanceof ObjectFacadingDelegator)) { final Scriptable threadLocalFacadedObj; final Map<Scriptable, WeakReference<Scriptable>> facadeByRealObject = this.facadeByRealObject.get(); if (facadeByRealObject != null) { final WeakReference<Scriptable> threadLocalFacadedObjRef = facadeByRealObject.get(obj); threadLocalFacadedObj = threadLocalFacadedObjRef != null ? threadLocalFacadedObjRef.get() : null; } else { threadLocalFacadedObj = null; this.facadeByRealObject.set(new WeakHashMap<Scriptable, WeakReference<Scriptable>>()); } if (threadLocalFacadedObj == null) { Map<Scriptable, WeakReference<Scriptable>> facadeByRealObjectAndReferenceScope = this.facadeByRealObjectAndReferenceScope .get(referenceScope); if (facadeByRealObjectAndReferenceScope == null) { synchronized (this.facadeByRealObjectAndReferenceScope) { facadeByRealObjectAndReferenceScope = this.facadeByRealObjectAndReferenceScope .get(referenceScope); if (facadeByRealObjectAndReferenceScope == null) { facadeByRealObjectAndReferenceScope = new WeakHashMap<Scriptable, WeakReference<Scriptable>>(); this.facadeByRealObjectAndReferenceScope.put(referenceScope, facadeByRealObjectAndReferenceScope); } } } WeakReference<Scriptable> globalFacadedObjectRef = facadeByRealObjectAndReferenceScope.get(obj); Scriptable globalFacadedObject = globalFacadedObjectRef != null ? globalFacadedObjectRef.get() : null; if (globalFacadedObject == null) { synchronized (facadeByRealObjectAndReferenceScope) { globalFacadedObjectRef = facadeByRealObjectAndReferenceScope.get(obj); globalFacadedObject = globalFacadedObjectRef != null ? globalFacadedObjectRef.get() : null; if (globalFacadedObject == null) { globalFacadedObject = this.toFacadedObjectImpl(obj, referenceScope, accessName); facadeByRealObjectAndReferenceScope.put(obj, new WeakReference<Scriptable>(globalFacadedObject)); } } } facadedObject = globalFacadedObject; this.facadeByRealObject.get().put(obj, new WeakReference<Scriptable>(facadedObject)); } else { facadedObject = threadLocalFacadedObj; } } else { facadedObject = obj; } return facadedObject; }
From source file:org.jhotdraw.samples.svg.figures.SVGImage.java
protected Object readResolve() throws ObjectStreamException { super.readResolve(); this.scaledImages = new WeakHashMap<Double, BufferedImage>(); return this; }