|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Resource
Encapsulates a system resource (file, database connection, etc). It is used to manage usage and availability of shared system resources. This interface allows monitoring a resource and helps preventing dead locks on it as well as being freed as soon as it is not being used. Data providers can provide implementations for their own resources. This is specially interesting when resources require a specific treatment beyond the standard shared file or connection, for instance to manage connections to a server through its own connection pool.
Method Summary | |
---|---|
void |
addConsumer(org.gvsig.fmap.dal.resource.spi.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. |
Object |
execute(ResourceAction action)
Executes an action which uses the current Resource . |
Object |
get()
Returns an object that represents the resource. |
int |
getConsumersCount()
Returns this resource's current number of consumers. |
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. |
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(org.gvsig.fmap.dal.resource.spi.ResourceConsumer consumer)
Removes a consumer from this resource's consumer list. |
void |
setData(Object data)
Sets a custom object as this resource's extended data. |
Method Detail |
---|
String getName() throws AccessResourceException
AccessResourceException
ResourceParameters getParameters()
long getLastTimeOpen()
long getLastTimeUsed()
boolean inUse()
boolean isOpen()
int openCount()
Object execute(ResourceAction action) throws ResourceExecuteException
Resource
.
runnable
- to execute
ResourceException
- if there is an error executing the action
ResourceExecuteException
void closeRequest() throws ResourceException
ResourceException
void addConsumer(org.gvsig.fmap.dal.resource.spi.ResourceConsumer consumer)
consumer
- the consumer that will be added to this resource's consumer list.void removeConsumer(org.gvsig.fmap.dal.resource.spi.ResourceConsumer consumer)
consumer
- the consumer that will be removed.int getConsumersCount()
Object get() throws AccessResourceException
AccessResourceException
Object getData()
void setData(Object data)
data
- a custom object containing data related to this resource.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |