1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 module hunt.pool.impl.PooledSoftReference; 18 19 // import java.lang.ref.SoftReference; 20 21 /** 22 * Extension of {@link DefaultPooledObject} to wrap pooled soft references. 23 * 24 * <p>This class is intended to be thread-safe.</p> 25 * 26 * @param <T> the type of the underlying object that the wrapped SoftReference 27 * refers to. 28 * 29 */ 30 // class PooledSoftReference(T) : DefaultPooledObject!(T) { 31 32 // /** SoftReference wrapped by this object */ 33 // private SoftReference!(T) reference; 34 35 // /** 36 // * Creates a new PooledSoftReference wrapping the provided reference. 37 // * 38 // * @param reference SoftReference to be managed by the pool 39 // */ 40 // this(SoftReference!(T) reference) { 41 // super(null); // Null the hard reference in the parent 42 // this.reference = reference; 43 // } 44 45 // /** 46 // * Returns the object that the wrapped SoftReference refers to. 47 // * <p> 48 // * Note that if the reference has been cleared, this method will return 49 // * null. 50 // * 51 // * @return Object referred to by the SoftReference 52 // */ 53 // override 54 // T getObject() { 55 // return reference.get(); 56 // } 57 58 // /** 59 // * {@inheritDoc} 60 // */ 61 // override 62 // string toString() { 63 // StringBuilder result = new StringBuilder(); 64 // result.append("Referenced Object: "); 65 // result.append(getObject().toString()); 66 // result.append(", State: "); 67 // synchronized (this) { 68 // result.append(getState().toString()); 69 // } 70 // return result.toString(); 71 // // TODO add other attributes 72 // // TODO encapsulate state and other attribute display in parent 73 // } 74 75 // /** 76 // * Returns the SoftReference wrapped by this object. 77 // * 78 // * @return underlying SoftReference 79 // */ 80 // synchronized SoftReference!(T) getReference() { 81 // return reference; 82 // } 83 84 // /** 85 // * Sets the wrapped reference. 86 // * 87 // * <p>This method exists to allow a new, non-registered reference to be 88 // * held by the pool to track objects that have been checked out of the pool. 89 // * The actual parameter <strong>should</strong> be a reference to the same 90 // * object that {@link #getObject()} returns before calling this method.</p> 91 // * 92 // * @param reference new reference 93 // */ 94 // synchronized void setReference(SoftReference!(T) reference) { 95 // this.reference = reference; 96 // } 97 // }