public interface ReferenceOwner
This can be useful, for example, in scenarios where it's necessary to track the owners of resources such as file handles, network sockets, or any other entities that need to be managed throughout their lifecycle.
Implementations of this interface can be used to associate owners with references, making it easier to monitor, debug, and manage resource ownership and ensure that resources are released properly.
| Modifier and Type | Field and Description |
|---|---|
static ReferenceOwner |
INIT
A predefined
ReferenceOwner instance representing an initial reference. |
static ReferenceOwner |
TMP
A predefined
ReferenceOwner instance representing a temporary reference. |
| Modifier and Type | Method and Description |
|---|---|
default int |
referenceId()
Returns a unique identifier (ID) for this reference owner.
|
default String |
referenceName()
Returns a human-readable name for this reference owner.
|
static ReferenceOwner |
temporary(String name)
Creates and returns a temporary with the given name.
|
static final ReferenceOwner INIT
ReferenceOwner instance representing an initial reference.
This instance is intended to be used as the first owner when none is provided.static final ReferenceOwner TMP
ReferenceOwner instance representing a temporary reference.
This can be used as a placeholder owner for temporary references, typically those which
do not have a clearly defined long-term owner.static ReferenceOwner temporary(String name)
When resource tracing is enabled, a new VanillaReferenceOwner is created with the specified name.
Otherwise, the predefined TMP instance is returned, regardless of the provided name.
name - The name to be assigned to the temporary reference owner, used for identification and debugging purposes.default int referenceId()
The default implementation uses the identity hash code of this reference owner instance as the ID.
default String referenceName()
The default implementation generates a name using the simple class name of the reference owner, followed by '@', and then the reference ID encoded in base 36.
Copyright © 2024. All rights reserved.