public interface IResourceHandle
The handle can be used to add and remove dependencies of a resource, to adjust the life-cycle handling of a resource and generally to hold on to a resource.
Resources that are not managed by hard references will not be collected as long as an associated resource handle is held onto.
Modifier and Type | Field | Description |
---|---|---|
static short |
HARD |
|
static short |
SOFT |
|
static short |
WEAK |
Modifier and Type | Method | Description |
---|---|---|
void |
addDependency(IResourceHandle rh) |
Adds a dependency for this resource.
|
void |
adjust(long ttl,
long exp,
short rm) |
Adjust the life-cycle handling of the single resource
|
<T> T |
as(java.lang.Class<T> clz) |
Retrieve a resource representation adhering to the passed-on type.
|
void |
attach(java.lang.Object o) |
Attach the handle to an object.
|
void |
detach(java.lang.Object o) |
Detach the handle from an object.
|
IResourceObserver |
getObserver() |
Get the observer, an id to the handle that does not determine the handles life cycle
|
IResourceInfo |
getResourceInfo() |
Gets resource info
|
boolean |
hasDependency(IResourceHandle rh) |
Checks whether this handle depends on the resource associated to the passed-in handle.
|
void |
invalidate(boolean forced) |
Invalidate the resource.
|
void |
removeDependency(IResourceHandle rh) |
Removes a dependency from this resource.
|
static final short WEAK
static final short SOFT
static final short HARD
void adjust(long ttl, long exp, short rm)
ttl
- a time-to-live parameter. After each access, the resource
will be kept by a strong reference at least ttl ms.exp
- an absolute point in time. When reaching exp, the resource will be automatically
invalidated. Set to Long.MAX_VALUE
by default.rm
- the type of reference applied when holding onto the resource (see WEAK
, SOFT
, HARD
).void invalidate(boolean forced) throws ResourceBusyException
forced
- if true
the resource cannot veto by throwing a ResourceBusyException. Otherwise it can.ResourceBusyException
<T> T as(java.lang.Class<T> clz)
clz
- the expected return typeboolean hasDependency(IResourceHandle rh)
void addDependency(IResourceHandle rh)
void removeDependency(IResourceHandle rh)
IResourceInfo getResourceInfo()
IResourceObserver getObserver()
void attach(java.lang.Object o)
void detach(java.lang.Object o)
attach(Object)
.