PooledSoftReference (Apache Tomcat 9.0.37 API Documentation)

org.apache.tomcat.dbcp.pool2.impl

## Class PooledSoftReference<T>

- java.lang.Object
- - org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject<T>
  - - org.apache.tomcat.dbcp.pool2.impl.PooledSoftReference<T>

- Type Parameters:
    `T` - the type of the underlying object that the wrapped SoftReference refers to.
  All Implemented Interfaces:
    Comparable<PooledObject<T>>, PooledObject<T>

      public class PooledSoftReference<T>
      extends DefaultPooledObject<T>

  Extension of `DefaultPooledObject` to wrap pooled soft references.

  This class is intended to be thread-safe.

  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PooledSoftReference(SoftReference<T> reference)` Creates a new PooledSoftReference wrapping the provided reference.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `getObject()` Returns the object that the wrapped SoftReference refers to.
    `SoftReference<T>` | `getReference()` Returns the SoftReference wrapped by this object.
    `void` | `setReference(SoftReference<T> reference)` Sets the wrapped reference.
    `String` | `toString()` Provides a String form of the wrapper for debug purposes.

    - ### Methods inherited from class org.apache.tomcat.dbcp.pool2.impl.DefaultPooledObject

      `allocate, compareTo, deallocate, endEvictionTest, getActiveTimeMillis, getBorrowedCount, getCreateTime, getIdleTimeMillis, getLastBorrowTime, getLastReturnTime, getLastUsedTime, getState, invalidate, markAbandoned, markReturning, printStackTrace, setLogAbandoned, setRequireFullStackTrace, startEvictionTest, use`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tomcat.dbcp.pool2.PooledObject

      `equals, hashCode`

- - ### Constructor Detail

    - #### PooledSoftReference

          public PooledSoftReference(SoftReference<T> reference)

      Creates a new PooledSoftReference wrapping the provided reference.
      Parameters:
        `reference` - SoftReference to be managed by the pool

  - ### Method Detail

    - #### getObject

          public T getObject()

      Returns the object that the wrapped SoftReference refers to.

      Note that if the reference has been cleared, this method will return null.

      Specified by:
        `getObject` in interface `PooledObject<T>`
      Overrides:
        `getObject` in class `DefaultPooledObject<T>`
      Returns:
        Object referred to by the SoftReference

    - #### toString

          public String toString()

      Provides a String form of the wrapper for debug purposes. The format is not fixed and may change at any time.

      Specified by:
        `toString` in interface `PooledObject<T>`
      Overrides:
        `toString` in class `DefaultPooledObject<T>`

    - #### getReference

          public SoftReference<T> getReference()

      Returns the SoftReference wrapped by this object.
      Returns:
        underlying SoftReference

    - #### setReference

          public void setReference(SoftReference<T> reference)

      Sets the wrapped reference.

      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 should be a reference to the same object that `getObject()` returns before calling this method.

      Parameters:
        `reference` - new reference

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.