svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / resource / ResourceManager.java @ 40435
History | View | Annotate | Download (2.61 KB)
1 |
package org.gvsig.fmap.dal.resource; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
|
5 |
import org.gvsig.fmap.dal.exception.DataException; |
6 |
import org.gvsig.fmap.dal.resource.exception.DisposeResorceManagerException; |
7 |
import org.gvsig.tools.observer.Observer; |
8 |
import org.gvsig.tools.observer.WeakReferencingObservable; |
9 |
|
10 |
/**
|
11 |
* This interface is the responsible of shared resources management.
|
12 |
*
|
13 |
* Allows getting a resource, iterating over the available resources, and
|
14 |
* collecting resources to free them as they become unused
|
15 |
*
|
16 |
*/
|
17 |
public interface ResourceManager extends WeakReferencingObservable { |
18 |
public Resource getResource(String name); |
19 |
|
20 |
/**
|
21 |
* Returns an iterator over the available resources.
|
22 |
*
|
23 |
* @return
|
24 |
* iterator over the resources.
|
25 |
*/
|
26 |
public Iterator iterator(); |
27 |
|
28 |
/**
|
29 |
* Iterates over the resources and frees them if they are ready to be freed
|
30 |
* or try to close them if they are idle.
|
31 |
*
|
32 |
* @throws DataException
|
33 |
* @see {@link ResourceManager#getTimeToBeIdle()}
|
34 |
* {@link ResourceManager#setTimeToBeIdle(int)}
|
35 |
*/
|
36 |
public void collectResources() throws DataException; |
37 |
|
38 |
/**
|
39 |
* Returns the wait time to consider that a resource is idle in seconds.
|
40 |
* Used in collect resouces action. <br>
|
41 |
* if is lower than 1 never is idle.
|
42 |
*
|
43 |
* @return seconds
|
44 |
*
|
45 |
* @see {@link ResourceManager#collectResources()}
|
46 |
* @see {@link ResourceManager#startResourceCollector(long, Observer)}
|
47 |
*/
|
48 |
public int getTimeToBeIdle(); |
49 |
|
50 |
/**
|
51 |
* Sets the wait time to consider that a resource is idle. Used in collect
|
52 |
* resouces action. <br>
|
53 |
* if is lower than 1 never is idle.
|
54 |
*
|
55 |
* @see {@link ResourceManager#collectResources()}
|
56 |
* @see {@link ResourceManager#startResourceCollector(long, Observer)}
|
57 |
*/
|
58 |
|
59 |
public void setTimeToBeIdle(int seconds); |
60 |
|
61 |
/**
|
62 |
* Initializes the resource collection background process. Allows setting
|
63 |
* of the delay between each execution of the collector and also an
|
64 |
* observer to be notified on each execution.
|
65 |
*
|
66 |
* @param milis
|
67 |
* delay between each execution of the resource collection process, in milliseconds.
|
68 |
*
|
69 |
* @param observer
|
70 |
* an observer that will be notified on each execution of the resource collection process.
|
71 |
*/
|
72 |
public void startResourceCollector(long milis, Observer observer); |
73 |
|
74 |
/**
|
75 |
* Stops successive executions of the resource collector process. It does not interrupt
|
76 |
* the process if it is currently running, but it will not be executed anymore times.
|
77 |
*/
|
78 |
public void stopResourceCollector(); |
79 |
|
80 |
/**
|
81 |
* Close all register resources.
|
82 |
*
|
83 |
* @throws DataException
|
84 |
*/
|
85 |
public void closeResources() throws DataException; |
86 |
|
87 |
public void dispose() throws DisposeResorceManagerException; |
88 |
|
89 |
} |