Top Description Fields Constructors Methods
org.apache.commons.pool2.impl

public Class PooledSoftReference<T>

extends DefaultPooledObject<T>
Class Inheritance
Type Parameters
<T>
the type of the underlying object that the wrapped SoftReference refers to.
Imports
java.lang.ref.SoftReference

Extension of DefaultPooledObject to wrap pooled soft references.

This class is intended to be thread-safe.

Since
2.0

Field Summary

Modifier and TypeField and Description
private volatile SoftReference<T>
reference

SoftReference wrapped by this object

Constructor Summary

AccessConstructor and Description
public
PooledSoftReference(final SoftReference<T>
SoftReference to be managed by the pool
reference
)

Creates a new PooledSoftReference wrapping the provided reference.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

Object referred to by the SoftReference
getObject
()

Overrides org.apache.commons.pool2.impl.DefaultPooledObject.getObject.

Implements org.apache.commons.pool2.PooledObject.getObject.

Gets the object that the wrapped SoftReference refers to.

public synchronized SoftReference<T>

Returns:

underlying SoftReference
getReference
()

Gets the SoftReference wrapped by this object.

public synchronized void
setReference(final SoftReference<T>
new reference
reference
)

Sets the wrapped reference.

public String
toString()

Overrides org.apache.commons.pool2.impl.DefaultPooledObject.toString.

Implements org.apache.commons.pool2.PooledObject.toString.

Gets a String form of the wrapper for debug purposes.

Inherited from org.apache.commons.pool2.impl.DefaultPooledObject:
allocatecompareTodeallocateendEvictionTestgetActiveTimeMillisgetBorrowedCountgetCreateInstantgetCreateTimegetIdleDurationgetIdleTimegetIdleTimeMillisgetLastBorrowInstantgetLastBorrowTimegetLastReturnInstantgetLastReturnTimegetLastUsedInstantgetLastUsedTimegetStateinvalidatemarkAbandonedmarkReturningprintStackTracesetLogAbandonedsetRequireFullStackTracestartEvictionTestuse

Field Detail

referenceback to summary
private volatile SoftReference<T> reference

SoftReference wrapped by this object

Constructor Detail

PooledSoftReferenceback to summary
public PooledSoftReference(final SoftReference<T> reference)

Creates a new PooledSoftReference wrapping the provided reference.

Parameters
reference:SoftReference<T>

SoftReference to be managed by the pool

Method Detail

getObjectback to summary
public T getObject()

Overrides org.apache.commons.pool2.impl.DefaultPooledObject.getObject.

Implements org.apache.commons.pool2.PooledObject.getObject.

Gets the object that the wrapped SoftReference refers to.

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

Returns:T

Object referred to by the SoftReference

Annotations
@Override
getReferenceback to summary
public synchronized SoftReference<T> getReference()

Gets the SoftReference wrapped by this object.

Returns:SoftReference<T>

underlying SoftReference

setReferenceback to summary
public synchronized void setReference(final 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:SoftReference<T>

new reference

toStringback to summary
public String toString()

Overrides org.apache.commons.pool2.impl.DefaultPooledObject.toString.

Implements org.apache.commons.pool2.PooledObject.toString.

Doc from org.apache.commons.pool2.PooledObject.toString.

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

Annotations
@Override