Home | History | Annotate | Download | only in tsccm
      1 /*
      2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntryRef.java $
      3  * $Revision: 674186 $
      4  * $Date: 2008-07-05 05:18:54 -0700 (Sat, 05 Jul 2008) $
      5  *
      6  * ====================================================================
      7  *
      8  *  Licensed to the Apache Software Foundation (ASF) under one or more
      9  *  contributor license agreements.  See the NOTICE file distributed with
     10  *  this work for additional information regarding copyright ownership.
     11  *  The ASF licenses this file to You under the Apache License, Version 2.0
     12  *  (the "License"); you may not use this file except in compliance with
     13  *  the License.  You may obtain a copy of the License at
     14  *
     15  *      http://www.apache.org/licenses/LICENSE-2.0
     16  *
     17  *  Unless required by applicable law or agreed to in writing, software
     18  *  distributed under the License is distributed on an "AS IS" BASIS,
     19  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20  *  See the License for the specific language governing permissions and
     21  *  limitations under the License.
     22  * ====================================================================
     23  *
     24  * This software consists of voluntary contributions made by many
     25  * individuals on behalf of the Apache Software Foundation.  For more
     26  * information on the Apache Software Foundation, please see
     27  * <http://www.apache.org/>.
     28  *
     29  */
     30 
     31 package org.apache.http.impl.conn.tsccm;
     32 
     33 
     34 import java.lang.ref.WeakReference;
     35 import java.lang.ref.ReferenceQueue;
     36 
     37 import org.apache.http.conn.routing.HttpRoute;
     38 
     39 
     40 
     41 /**
     42  * A weak reference to a {@link BasicPoolEntry BasicPoolEntry}.
     43  * This reference explicitly keeps the planned route, so the connection
     44  * can be reclaimed if it is lost to garbage collection.
     45  *
     46  * @deprecated Please use {@link java.net.URL#openConnection} instead.
     47  *     Please visit <a href="http://android-developers.blogspot.com/2011/09/androids-http-clients.html">this webpage</a>
     48  *     for further details.
     49  */
     50 @Deprecated
     51 public class BasicPoolEntryRef extends WeakReference<BasicPoolEntry> {
     52 
     53     /** The planned route of the entry. */
     54     private final HttpRoute route;
     55 
     56 
     57     /**
     58      * Creates a new reference to a pool entry.
     59      *
     60      * @param entry   the pool entry, must not be <code>null</code>
     61      * @param queue   the reference queue, or <code>null</code>
     62      */
     63     public BasicPoolEntryRef(BasicPoolEntry entry,
     64                              ReferenceQueue<Object> queue) {
     65         super(entry, queue);
     66         if (entry == null) {
     67             throw new IllegalArgumentException
     68                 ("Pool entry must not be null.");
     69         }
     70         route = entry.getPlannedRoute();
     71     }
     72 
     73 
     74     /**
     75      * Obtain the planned route for the referenced entry.
     76      * The planned route is still available, even if the entry is gone.
     77      *
     78      * @return      the planned route
     79      */
     80     public final HttpRoute getRoute() {
     81         return this.route;
     82     }
     83 
     84 } // class BasicPoolEntryRef
     85 
     86