Package java.lang.ref

Examples of java.lang.ref.SoftReference


    /**
     * Returns a thread local QNameCache
     */
    public static QNameCache getQNameCache ( )
    {
        SoftReference softRef = (SoftReference)_threadLocalLoaderQNameCache.get();
        QNameCache qnameCache = (QNameCache) (softRef).get();
        if (qnameCache==null)
        {
            qnameCache = new QNameCache( 32 );
            _threadLocalLoaderQNameCache.set(new SoftReference(qnameCache));
        }
        return qnameCache;
    }
View Full Code Here


      throw new NullPointerException( "Key to get cannot be null" );
    }

    clearObsoleteReferences();

    SoftReference ref = (SoftReference) softRefCache.get( key );
    if ( ref != null ) {
      Object refValue = ref.get();
      if ( refValue != null ) {
        // This ensures recently used entries are strongly-reachable
        strongRefCache.put( key, refValue );
        return refValue;
      }
View Full Code Here

    }

    clearObsoleteReferences();

    strongRefCache.put( key, value );
    SoftReference ref = (SoftReference) softRefCache.put(
        key,
        new KeyedSoftReference( key, value, referenceQueue )
    );

    return ( ref != null ) ? ref.get() : null;
  }
View Full Code Here

        doTheWork(cls, ret);

        // We did it
        synchronized (this) {
            workInProgress.remove(cls);
            workDone.put(cls, new SoftReference(ret));
            notifyAll();
        }

        return ret;
    }
View Full Code Here

    /**
     * Lookup an analysis in the fully done map.
     */
    private ContainerAnalysis lookupDone(Class cls) {
        SoftReference ref = (SoftReference) workDone.get(cls);
        if (ref == null)
            return null;
        ContainerAnalysis ret = (ContainerAnalysis) ref.get();
        if (ret == null)
            workDone.remove(cls); // clear map entry if soft ref. was cleared.
        return ret;
    }
View Full Code Here

    }

    protected CachableRed setupCache(CachableRed img) {
        if ((lastCR == null) ||
            (img != lastCR.get())) {
            lastCR    = new SoftReference(img);
            lastCache = null;
        }

        Object o = null;
        if (lastCache != null)
            o = lastCache.get();
        if (o != null)
            return (CachableRed)o;

        img       = new TileCacheRed(img);
        lastCache = new SoftReference(img);
        return img;
    }
View Full Code Here

        Asset result = TapestryInternalUtils.getAndDeref(cache, resource);

        if (result == null)
        {
            result = createAssetFromResource(resource);
            cache.put(resource, new SoftReference(result));
        }

        return result;
    }
View Full Code Here

    }
  }

  protected Reference createReference(FileObject file, ReferenceQueue refqueue)
  {
    return new SoftReference(file, refqueue);
  }
View Full Code Here

        }

        boolean shouldDestroy = !success;
        _numActive--;
        if(success) {
            _pool.add(new SoftReference(obj, refQueue));
        }
        notifyAll(); // _numActive has changed

        if (shouldDestroy && _factory != null) {
            try {
View Full Code Here

            _factory.passivateObject(obj);
        }

        boolean shouldDestroy = !success;
        if(success) {
            _pool.add(new SoftReference(obj, refQueue));
            notifyAll(); // _numActive has changed
        }

        if(shouldDestroy) {
            try {
View Full Code Here

TOP

Related Classes of java.lang.ref.SoftReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.