Examples of SoftReference


Examples of java.lang.ref.SoftReference

    {
        clean();
        if ( _currentSize <= _sizeB )
        {
            buffer.clear();
            SoftReference ref = new SoftReference( buffer, this._refQueue );
            _pool.add( ref );
            _currentSize += buffer.capacity();
            LOG.log( Level.FINEST, "Pushed back buffer with capacity of " + buffer.capacity() + ". Pool max size: "
                    + _sizeB + " Current pool size: " + _currentSize );
        }
View Full Code Here

Examples of java.lang.ref.SoftReference

   * @return a cached instance
   */
  public static SimpleFontExtensionHelper getInstance()
  {
    SimpleFontExtensionHelper instance = null;
    SoftReference instanceRef = (SoftReference) threadInstances.get();
    if (instanceRef != null)
    {
      instance = (SimpleFontExtensionHelper) instanceRef.get();
    }
    if (instance == null)
    {
      instance = new SimpleFontExtensionHelper();
      threadInstances.set(new SoftReference(instance));
    }
    return instance;
  }
View Full Code Here

Examples of java.lang.ref.SoftReference

   * @return a cached instance
   */
  public static JRStyledTextParser getInstance()
  {
    JRStyledTextParser instance = null;
    SoftReference instanceRef = (SoftReference) threadInstances.get();
    if (instanceRef != null)
    {
      instance = (JRStyledTextParser) instanceRef.get();
    }
    if (instance == null)
    {
      instance = new JRStyledTextParser();
      threadInstances.set(new SoftReference(instance));
    }
    return instance;
  }
View Full Code Here

Examples of java.lang.ref.SoftReference

                    // Use the same loader, allowing the new class access to
                    // same package protected members.
                    loader = (Loader) parent;
                    break getLoader;
                }
                SoftReference ref = (SoftReference) cLoaders.get(parent);
                if (ref != null) {
                    loader = (Loader) ref.get();
                    if (loader != null && loader.isValid()) {
                        break getLoader;
                    }
                    ref.clear();
                }
                loader = parent == null ? new Loader() : new Loader(parent);
                cLoaders.put(parent, new SoftReference(loader));
            }

            if (explicit) {
                reserveCheck: {
                    for (int i=0; i<2; i++) {
                        if (loader.reserveName(name)) {
                            try {
                                loader.loadClass(name);
                            } catch (ClassNotFoundException e) {
                                break reserveCheck;
                            }
                        }
                        if (i > 0) {
                            throw new IllegalStateException
                                ("Class name already reserved: " + name);
                        }
                        // Make a new loader and try again.
                        loader = parent == null ? new Loader() : new Loader(parent);
                    }

                    // Save new loader.
                    cLoaders.put(parent, new SoftReference(loader));
                }
            } else {
                for (int tryCount = 0; tryCount < 1000; tryCount++) {
                    name = null;
                   
View Full Code Here

Examples of java.lang.ref.SoftReference

   
    private synchronized XMLInputFactory getInputFactory() {
      XMLInputFactory inputFactory = (XMLInputFactory) factoryRef.get();
      if (inputFactory == null) {
        inputFactory = createInputFactory();
        factoryRef = new SoftReference(inputFactory);
      }
      return inputFactory;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

//    }
   
    Map methods = (Map) ENCODING_METHODS.get();
    if (methods == null) {
      methods = Collections.synchronizedMap(new HashMap());
      ENCODING_METHODS = new SoftReference(methods);
    }

    Method method = (Method) methods.get(writer.getClass().getName());
    if (method == null) { // not yet cached?
      method = NOT_AVAILABLE;
View Full Code Here

Examples of java.lang.ref.SoftReference

      log.debug("putFile: " + file.getName());
    }

    Map files = getOrCreateFilesystemCache(file.getFileSystem());

    Reference ref = new SoftReference(file, refqueue);
    FileSystemAndNameKey key = new FileSystemAndNameKey(file
        .getFileSystem(), file.getName());

    synchronized (files)
    {
View Full Code Here

Examples of java.lang.ref.SoftReference

  {
    Map files = getOrCreateFilesystemCache(filesystem);

    synchronized (files)
    {
      SoftReference ref = (SoftReference) files.get(name);
      if (ref == null)
      {
        return null;
      }

      FileObject fo = (FileObject) ref.get();
      if (fo == null)
      {
        removeFile(filesystem, name);
      }
      return fo;
View Full Code Here

Examples of java.lang.ref.SoftReference

  public void set(Object value) {
    super.set(wrap(value));
  }
 
  private static SoftReference wrap(Object value) {
    return new SoftReference(value);
  }
View Full Code Here

Examples of java.lang.ref.SoftReference

    public void set(Object value) {
      super.set(wrap(value));
    }
   
    private static SoftReference wrap(Object value) {
      return new SoftReference(value);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.