Package java.lang.ref

Examples of java.lang.ref.Reference$ReferenceHandler


    * @return     Dereferenced object.
    */
   @SuppressWarnings("unchecked")
   public static Object deref(final Object obj) {
      if (obj != null && obj instanceof Reference) {
         Reference ref = (Reference)obj;
         return ref.get();
      }

      return obj;
   }
View Full Code Here


    * @param obj  Object to dereference.
    * @return     Dereferenced object.
    */
   public static Object deref(final Object obj) {
      if (obj != null && obj instanceof Reference) {
         Reference ref = (Reference)obj;
         return ref.get();
      }

      return obj;
   }
View Full Code Here

     * @param md The method descriptor
     * @return The cached method
     */
    private static Method getCachedMethod(MethodDescriptor md) {
        if (CACHE_METHODS) {
            Reference methodRef = (Reference)cache.get(md);
            if (methodRef != null) {
                return (Method)methodRef.get();
            }
        }
        return null;
    }
View Full Code Here

        public V get();
    }
   
    private class ReferenceQueueRunner extends ReferenceQueue implements Runnable {
        public void run() {
            Reference ref = null;
            while (true) {
                try {
                    ref = this.remove();
                    if (ref != null) {
                        ref.clear();
                    }
                } catch (InterruptedException e) {
                    //e.printStackTrace();
                }
            }
View Full Code Here

        if (val == null)
            return true;

        if (!(val instanceof Reference))
            return false;
        Reference ref = (Reference)val;
        val = ref.get();
        if (val == null)
            return true;
        if (val instanceof BufferedImage)
            return true;
View Full Code Here

            while (!shutdown) {
                try {
                    // remove the next reference and process it, a timeout
                    // is used so that the thread does not block indefinitely
                    // and therefore keep the thread from shutting down
                    Reference ref = REFERENCE_QUEUE.remove(1000);
                    if (ref != null) {
                        handleReference(ref);
                    }
                } catch (InterruptedException e) {
                    LOG.debug("ReferenceQueueThread interrupted", e);
View Full Code Here

       
        synchronized (REFERENCE_TO_CONNECTION_SOURCE) {
           
            Iterator referenceIter = REFERENCE_TO_CONNECTION_SOURCE.keySet().iterator();
            while (referenceIter.hasNext()) {
                Reference ref = (Reference) referenceIter.next();
                ConnectionSource source =
                    (ConnectionSource) REFERENCE_TO_CONNECTION_SOURCE.get(ref);
                if (source.connectionPool == connectionPool) {
                    referenceIter.remove();
                    HttpConnection connection = (HttpConnection) ref.get();
                    if (connection != null) {
                        connectionsToClose.add(connection);
                    }
                }
            }
View Full Code Here

     * and dispose of any corresponding images.
     */
    public final void run() {
      while (true) {
        // Get the next reference to dispose.
        Reference reference = null;
        // Block until a reference becomes available in the queue
        try {
          reference = referenceQueue.remove();
        } catch (final InterruptedException e) {
          // Reference will be null.
        }

        // Check to see if we've been told to stop.
        if (reference == endMarker) {
          // Clean up the image map
          break;
        }

        // Image disposal - need to traverse the set of keys, since the
        // image descriptor has been cleaned. No way to directly
        // retrieve the equivalence set from the map . This could be
        // improved (with better search/sort).
        if (reference instanceof ImageCacheWeakReference) {
          removeReferenceEnqueued((ImageCacheWeakReference) reference);
        }

        // Clear the reference.
        if (reference != null) {
          reference.clear();
        }

      }
    }
View Full Code Here

    * @return     Dereferenced object.
    */
   @SuppressWarnings("unchecked")
   public static Object deref(final Object obj) {
      if (obj != null && obj instanceof Reference) {
         Reference ref = (Reference)obj;
         return ref.get();
      }

      return obj;
   }
View Full Code Here

  // Updates the object ID table, removing IDs whose objects have
  // been garbage collected.
  private void _update ()
  {
    Reference ref;
    while ((ref = _refQueue.poll ()) != null)
      {
  ObjectId id = (ObjectId) _oidTable.get (ref);
  _oidTable.remove (ref);
  _idTable.remove (new Long (id.getId ()));
View Full Code Here

TOP

Related Classes of java.lang.ref.Reference$ReferenceHandler

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.