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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Tacquire()final voidclose()Close the resource and free any managed resources it might own.final booleanisClosed()AResourceis closed either following a call to theResource.close()method or by the resource being transfered by way of theResource.transfer()method.protected final booleanisShared()protected abstract voidprotected abstract RuntimeExceptionfinal Ttransfer()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:ResourceClose 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:ResourceTransfers 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:ResourceAResourceis 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
-