• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java $
3  * $Revision: 652721 $
4  * $Date: 2008-05-01 17:32:20 -0700 (Thu, 01 May 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.ReferenceQueue;
35 
36 import org.apache.http.conn.OperatedClientConnection;
37 import org.apache.http.conn.ClientConnectionOperator;
38 import org.apache.http.conn.routing.HttpRoute;
39 import org.apache.http.impl.conn.AbstractPoolEntry;
40 
41 
42 
43 /**
44  * Basic implementation of a connection pool entry.
45  */
46 public class BasicPoolEntry extends AbstractPoolEntry {
47 
48     /**
49      * A weak reference to <code>this</code> used to detect GC of entries.
50      * Pool entries can only be GCed when they are allocated by an application
51      * and therefore not referenced with a hard link in the manager.
52      */
53     private final BasicPoolEntryRef reference;
54 
55     /**
56      * Creates a new pool entry.
57      *
58      * @param op      the connection operator
59      * @param route   the planned route for the connection
60      * @param queue   the reference queue for tracking GC of this entry,
61      *                or <code>null</code>
62      */
BasicPoolEntry(ClientConnectionOperator op, HttpRoute route, ReferenceQueue<Object> queue)63     public BasicPoolEntry(ClientConnectionOperator op,
64                           HttpRoute route,
65                           ReferenceQueue<Object> queue) {
66         super(op, route);
67         if (route == null) {
68             throw new IllegalArgumentException("HTTP route may not be null");
69         }
70         this.reference = new BasicPoolEntryRef(this, queue);
71     }
72 
getConnection()73     protected final OperatedClientConnection getConnection() {
74         return super.connection;
75     }
76 
getPlannedRoute()77     protected final HttpRoute getPlannedRoute() {
78         return super.route;
79     }
80 
getWeakRef()81     protected final BasicPoolEntryRef getWeakRef() {
82         return this.reference;
83     }
84 
85 
86 } // class BasicPoolEntry
87 
88 
89