|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DisposableResourceHolder
DisposableResourceHolder defines the interface for objects holding
disposable resources.
A disposable resource is any kind of object that can be disposed of
according to a given disposal strategy.
DisposableResourceHolder keeps track of the last time the resource is
accessed to support ellapsed time ResourceDisposabilityStrategies.
For example, if you are handling large images that you can regenerate
at will, the DisposableResourceHolder will hold the image, and if not
accessed for let's say 60 secs then it discards the image
(sets its reference to null) so that it can be GCed.
Within the context of JHotDraw, HTMLTextAreaFigure uses
DisposableResourceHolders to handle the HTML generated image, but if the
figure is not displayed (out of the display area or in a background view) then
the image is disposed of after a while and the HTMLTextAreaFigure will regenerate
it the next time it is displayed.
A resource may be locked so that its user can be sure it will not be
disposed of while in use. After finished using it it should be unlocked so as
to reintegrate it to the disposal strategy.
DisposableResourceManager
,
StandardDisposableResourceManager
,
ResourceDisposabilityStrategy
,
DisposableResourceManagerFactory
,
StandardDisposableResourceHolder
Method Summary | |
---|---|
java.lang.Object |
clone()
Makes a clone the this |
void |
dispose()
Disposes of the resource immediately. |
long |
getDisposableDelay()
Gets the disposableDelay |
long |
getLastTimeAccessed()
Gets the lastTimeAccessed attribute of the DisposableResourceHolder object |
java.lang.Object |
getResource()
Gets the resource |
boolean |
isAvailable()
Returns true if the resource is still available |
boolean |
isLocked()
True if the resource is locked |
void |
lock()
Locks the resource so it cannot be automatically disposed of until unlock is called. |
void |
resetDelay()
Resets the disposing delay so as to restart the time counter |
void |
setDisposableDelay(long millis)
Sets the disposableDelay |
void |
setResource(java.lang.Object resource)
Sets the resource |
void |
unlock()
Unlocks the resource so it can be automatically disposed of again. |
Method Detail |
---|
java.lang.Object getResource() throws java.lang.NullPointerException
java.lang.NullPointerException
- If the resource was disposed ofjava.lang.Object clone()
void setResource(java.lang.Object resource)
resource
- The new resource valuevoid setDisposableDelay(long millis)
millis
- The new disposableDelay valuelong getDisposableDelay()
void resetDelay()
long getLastTimeAccessed()
void dispose()
boolean isAvailable()
void lock()
void unlock()
boolean isLocked()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |