Class SharedResource<T extends Resource<T>>
java.lang.Object
org.apache.qpid.protonj2.resource.SharedResource<T>
- Type Parameters:
T
- The resource type that whose references are being tracked.
- All Implemented Interfaces:
AutoCloseable
,Resource<T>
- Direct Known Subclasses:
Netty4ToProtonBufferAdapter
,Netty5ToProtonBufferAdapter
,ProtonByteArrayBuffer
,ProtonCompositeBufferImpl
public abstract class SharedResource<T extends Resource<T>>
extends Object
implements Resource<T>, AutoCloseable
A referenced resource is one in which a number of objects can claim reference
and the resource will not close or free claimed resources until all references
have been released.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final T
acquire()
final void
close()
Close the resource and free any managed resources it might own.final boolean
isClosed()
AResource
is closed either following a call to theResource.close()
method or by the resource being transfered by way of theResource.transfer()
method.protected final boolean
isShared()
protected abstract void
protected abstract RuntimeException
final T
transfer()
Transfers ownership of this resource from one owner to another.protected abstract T
-
Constructor Details
-
SharedResource
public SharedResource()
-
-
Method Details
-
acquire
-
close
public final void close()Description copied from interface:Resource
Close the resource and free any managed resources it might own. Calling close on a closed resource should not result in any exceptions being thrown. -
transfer
Description copied from interface:Resource
Transfers ownership of this resource from one owner to another.Upon transferring a resource the original referenced value is closed and its contents are migrated to a new view that has the same state as the original view but it now the property of the caller and who's life-cycle now must be managed by the caller.
-
isClosed
public final boolean isClosed()Description copied from interface:Resource
AResource
is closed either following a call to theResource.close()
method or by the resource being transfered by way of theResource.transfer()
method. -
releaseResourceOwnership
protected abstract void releaseResourceOwnership() -
transferTheResource
-
resourceIsClosedException
-