Package java.lang.ref

Examples of java.lang.ref.WeakReference


  
   /** @param callback The handle to callback a client (is checked already to be not null) */
   Container(boolean useWeakReference, I_Timeout callback, Object userData) {
      this.useWeakReference = useWeakReference;
      if (this.useWeakReference) {
         this.callback = new WeakReference(callback);
         if (userData != null)
            this.userData = new WeakReference(userData);
      }
      else {
         this.callback = callback;
         this.userData = userData;
      }
View Full Code Here


   }

   /** @return The callback handle can be null for weak references */
   I_Timeout getCallback() {
      if (this.useWeakReference) {
         WeakReference weak = (WeakReference)this.callback;
         return (I_Timeout)weak.get();
      }
      else {
         return (I_Timeout)this.callback;
      }
   }
View Full Code Here

   Object getUserData() {
      if (this.userData == null) {
         return null;
      }
      if (this.useWeakReference) {
         WeakReference weak = (WeakReference)this.userData;
         return weak.get();
      }
      else {
         return this.userData;
      }
   }
View Full Code Here

            this.childs = new HashMap();
         }
         if (doClone) {
            ContextNode clone = child.getClone();
            clone.parent = this;
            this.childs.put(clone.getAbsoluteName(), new WeakReference(clone));
         }
         else {
            if (child.parent != null && this != child.parent) {
               // If child had another parent already remove it
               child.parent.removeChild(child);
            }
            child.parent = this;
            this.childs.put(child.getAbsoluteName(), new WeakReference(child));
         }
      }
      return true;
   }
View Full Code Here

                                                     Component component) {
        // ATTN: component has a strong reference to window via chain
        // of Component.parent fields.  Since WeakHasMap refers to its
        // values strongly, we need to break the strong link from the
        // value (component) back to its key (window).
        WeakReference weakValue = null;
        if (component != null) {
            weakValue = new WeakReference(component);
        }
        mostRecentFocusOwners.put(window, weakValue);
    }
View Full Code Here

    /*
     * Please be careful changing this method! It is called from
     * javax.swing.JComponent.runInputVerifier() using reflection.
     */
    static synchronized Component getMostRecentFocusOwner(Window window) {
        WeakReference weakValue =
            (WeakReference)mostRecentFocusOwners.get(window);
        return weakValue == null ? null : (Component)weakValue.get();
    }
View Full Code Here

    {
        if (Thread.currentThread() != dispatchThread) {
            return;
        }

        currentEvent = new WeakReference(e);

        // This series of 'instanceof' checks should be replaced with a
        // polymorphic type (for example, an interface which declares a
        // getWhen() method). However, this would require us to make such
        // a type public, or to place it in sun.awt. Both of these approaches
View Full Code Here

      // Remove ourself from any previous parent.
      if (parent != null) {
    // assert parent.kids != null;
    for (Iterator iter = parent.kids.iterator(); iter.hasNext(); ) {
        WeakReference ref = (WeakReference) iter.next();
        Logger kid = (Logger) ref.get();
        if (kid == this) {
            iter.remove();
      break;
        }
     }
    // We have now removed ourself from our parents' kids.
      }

      // Set our new parent.
      parent = newParent;
      if (parent.kids == null) {
          parent.kids = new ArrayList(2);
      }
      parent.kids.add(new WeakReference(this));

      // As a result of the reparenting, the effective level
      // may have changed for us and our children.
      updateEffectiveLevel();
View Full Code Here

  // System.err.println("effective level: \"" + getName() + "\" := " + level);

  // Recursively update the level on each of our kids.
  if (kids != null) {
      for (int i = 0; i < kids.size(); i++) {
          WeakReference ref = (WeakReference)kids.get(i);
    Logger kid = (Logger) ref.get();
    if (kid != null) {
        kid.updateEffectiveLevel();
     }
      }
  }
View Full Code Here

       * otherwise, remove the reserved entry.  In all cases, notify
       * all waiters on reserved entries in this cache.
       */
      synchronized (cache) {
    if (proxyClass != null) {
        cache.put(key, new WeakReference(proxyClass));
    } else {
        cache.remove(key);
    }
    cache.notifyAll();
      }
View Full Code Here

TOP

Related Classes of java.lang.ref.WeakReference

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.