ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/dbcp/pool2/impl/PooledSoftReference.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/dbcp/pool2/impl/PooledSoftReference.java
Status
scanned
Type
file
Name
PooledSoftReference.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3291 (3.2 KB)
MD5
3ff65f6d8ea7cdcf5cffe6add3ac139e
SHA1
bc749be354bd6c0cad9ff209e128126fbcf309de
SHA256
8cad7db2167243a06231ac2d3c85da96cb35a6fe8780e75210cab528d933a06a
SHA512

      
    
SHA1_git
c0c08fc1044b0180f2b1d0d2280a8151c38ba908
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
PooledSoftReference.java | 3.2 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.dbcp.pool2.impl; import java.lang.ref.SoftReference; /** * Extension of {@link DefaultPooledObject} to wrap pooled soft references. * * <p>This class is intended to be thread-safe.</p> * * @param <T> the type of the underlying object that the wrapped SoftReference * refers to. * * @since 2.0 */ public class PooledSoftReference<T> extends DefaultPooledObject<T> { /** SoftReference wrapped by this object */ private volatile SoftReference<T> reference; /** * Creates a new PooledSoftReference wrapping the provided reference. * * @param reference SoftReference to be managed by the pool */ public PooledSoftReference(final SoftReference<T> reference) { super(null); // Null the hard reference in the parent this.reference = reference; } /** * Gets the object that the wrapped SoftReference refers to. * <p> * Note that if the reference has been cleared, this method will return * null. * </p> * * @return Object referred to by the SoftReference */ @Override public T getObject() { return reference.get(); } /** * Gets the SoftReference wrapped by this object. * * @return underlying SoftReference */ public synchronized SoftReference<T> getReference() { return reference; } /** * Sets the wrapped reference. * * <p>This method exists to allow a new, non-registered reference to be * held by the pool to track objects that have been checked out of the pool. * The actual parameter <strong>should</strong> be a reference to the same * object that {@link #getObject()} returns before calling this method.</p> * * @param reference new reference */ public synchronized void setReference(final SoftReference<T> reference) { this.reference = reference; } @Override public String toString() { final StringBuilder result = new StringBuilder(); result.append("Referenced Object: "); result.append(getObject().toString()); result.append(", State: "); synchronized (this) { result.append(getState().toString()); } return result.toString(); // TODO add other attributes // TODO encapsulate state and other attribute display in parent } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
31.82
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-eb6b5ae0-4f88-4e9b-d67c-c6c8e733b1cd apache-2.0 Apache-2.0
URL Start line End line
https://www.apache.org/licenses/LICENSE-2.0 9 9