Package com.storedobject.common
Class ResourceHolder
java.lang.Object
com.storedobject.common.ResourceHolder
- All Implemented Interfaces:
ResourceOwner
An implementation of a simple
Usage note: A reference to the instance of this class must be kept inside the class where the instance is used. Otherwise, the "resource" will be garbage-collected soon because this class instance itself will get garbage-collected.
ResourceOwner
.Usage note: A reference to the instance of this class must be kept inside the class where the instance is used. Otherwise, the "resource" will be garbage-collected soon because this class instance itself will get garbage-collected.
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AutoCloseable
Get the resource.void
setResource
(AutoCloseable closeable) Set the resource.
-
Constructor Details
-
ResourceHolder
public ResourceHolder()Constructor.
-
-
Method Details
-
setResource
Set the resource. This will immediately register this owner withResourceDisposal
.- Parameters:
closeable
- Resource.
-
getResource
Get the resource.- Specified by:
getResource
in interfaceResourceOwner
- Returns:
- Resource.
-