Package java.lang.ref

Examples of java.lang.ref.WeakReference


    {
        private final WeakReference m_revision;

        private RevisionAsJarURL(BundleRevisionImpl revision)
        {
            m_revision = new WeakReference(revision);
        }
View Full Code Here


        if (!Util.isAccessible(_method)) {
            _method.setAccessible(true);
        }

        _parameterTypes = parameterTypes;
        _target = new WeakReference(target);
    }
View Full Code Here

    public void testDroppedThread() throws Exception {

        MultiThreadedHttpConnectionManager mthcm = new MultiThreadedHttpConnectionManager();
        HttpClient httpClient = createHttpClient(mthcm);
        WeakReference wr = new WeakReference(mthcm);

        GetMethod method = new GetMethod("/");
        httpClient.executeMethod(method);
        method.releaseConnection();

        mthcm = null;
        httpClient = null;
        method = null;
       
        System.gc();

        // this sleep appears to be necessary in order to give the JVM
        // time to clean up the miscellaneous pointers to the connection manager
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            fail("shouldn't be interrupted.");
        }

        Object connectionManager = wr.get();
        assertNull("connectionManager should be null", connectionManager);
    }   
View Full Code Here

        if(sinks == null) {
            sinks = new HashSet();
        }

        return sinks.add(new WeakReference(sink));
    }
View Full Code Here

     * necessary
     */
    private CellPropertiesJFrame getCellPropertiesJFrame() {
        if (cellPropertiesFrameRef == null || cellPropertiesFrameRef.get() == null) {
            CellPropertiesJFrame cellPropertiesFrame = new CellPropertiesJFrame();
            cellPropertiesFrameRef = new WeakReference(cellPropertiesFrame);
            return cellPropertiesFrame;
        } else {
            return cellPropertiesFrameRef.get();
        }
    }
View Full Code Here

        OCLHelper oclHelper = oclInstance.createOCLHelper();
        oclHelper.setContext(context());
        try {
          OCLExpression oclExpression = oclHelper.createQuery(body());
          oclQuery = oclInstance.createQuery(oclExpression);
          this.queryRef = new WeakReference(oclQuery);
          setStatus(IStatus.OK, null, null);
        } catch (ParserException e) {
          setStatus(IStatus.ERROR, e.getMessage(), e);
        }
      }
View Full Code Here

        return true;
      }
      IGraphicalEditPart part = createEditPart(view);
      if (part != null) {
        if (isAllowCaching()) {
          cachedPart = new WeakReference(part);
          cachedView = new WeakReference(view);
        }
        return true;
      }
    }
    return false;
View Full Code Here

                connection.setHttpConnectionManager(MultiThreadedHttpConnectionManager.this);
                numConnections++;
                hostPool.numConnections++;
       
                // add a weak reference to this connection
                referenceToHostConfig.put(new WeakReference(connection, referenceQueue),
                                          hostConfiguration);
            } else if (LOG.isDebugEnabled()) {
                if (hostPool.numConnections >= getMaxConnectionsPerHost()) {
                    LOG.debug("No connection allocated, host pool has already reached "
                        + "maxConnectionsPerHost, hostConfig=" + hostConfiguration
View Full Code Here

                connection.close();

                // make sure this connection will not be cleaned up again when garbage
                // collected
                for (Iterator iter = referenceToHostConfig.keySet().iterator(); iter.hasNext();) {
                    WeakReference connectionRef = (WeakReference) iter.next();
                    if (connectionRef.get() == connection) {
                        iter.remove();
                        connectionRef.enqueue();
                        break;
                    }
                }
               
                HostConnectionPool hostPool = getHostPool(connectionConfiguration);
View Full Code Here

   * that pass the supplied filter.
   * @see SinkFilter
   */
  public SinkTokenStream newSinkTokenStream(SinkFilter filter) {
    SinkTokenStream sink = new SinkTokenStream(this.cloneAttributes(), filter);
    this.sinks.add(new WeakReference(sink));
    return sink;
  }
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.