public interface Resource
Modifier and Type | Method and Description |
---|---|
void |
addConsumer(ResourceConsumer consumer)
Adds a consumer to this resource.
|
void |
closeRequest()
If the resource is not in use, calling this method will send a close request
to all consumers referencing this resource.
|
java.lang.Object |
execute(ResourceAction action)
Executes an action which uses the current
Resource . |
java.lang.Object |
get()
Returns an object that represents the resource.
|
int |
getConsumersCount()
Returns this resource's current number of consumers.
|
java.lang.Object |
getData()
Returns a custom object containing extended data relative to
this resource.
|
long |
getLastTimeOpen()
Returns the date and time in which this resource was opened for the last
time.
|
long |
getLastTimeUsed()
Returns the date and time in which this resource was accessed for the
last time.
|
java.lang.String |
getName()
Returns the resource's name.
|
ResourceParameters |
getParameters()
Returns the resource parameters.
|
boolean |
inUse()
Returns whether this resource is already in use by someone.
|
boolean |
isOpen()
Returns whether this resource is opened.
|
int |
openCount()
Returns the number of times this resource has been opened
since it was created.
|
void |
removeConsumer(ResourceConsumer consumer)
Removes a consumer from this resource's consumer list.
|
void |
setData(java.lang.Object data)
Sets a custom object as this resource's extended data.
|
java.lang.String getName() throws AccessResourceException
AccessResourceException
ResourceParameters getParameters()
long getLastTimeOpen()
long getLastTimeUsed()
boolean inUse()
boolean isOpen()
int openCount()
java.lang.Object execute(ResourceAction action) throws ResourceExecuteException
Resource
.runnable
- to executeResourceException
- if there is an error executing the actionResourceExecuteException
void closeRequest() throws ResourceException
ResourceException
void addConsumer(ResourceConsumer consumer)
consumer
- the consumer that will be added to this resource's consumer list.void removeConsumer(ResourceConsumer consumer)
consumer
- the consumer that will be removed.int getConsumersCount()
java.lang.Object get() throws AccessResourceException
AccessResourceException
java.lang.Object getData()
void setData(java.lang.Object data)
data
- a custom object containing data related to this resource.