Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / resource / ResourceManager.java @ 40333

History | View | Annotate | Download (2.61 KB)

1 24496 jmvivo
package org.gvsig.fmap.dal.resource;
2 23754 jjdelcerro
3
import java.util.Iterator;
4
5 24505 jmvivo
import org.gvsig.fmap.dal.exception.DataException;
6 28071 jmvivo
import org.gvsig.fmap.dal.resource.exception.DisposeResorceManagerException;
7
import org.gvsig.tools.observer.Observer;
8 24268 jjdelcerro
import org.gvsig.tools.observer.WeakReferencingObservable;
9 23754 jjdelcerro
10 24975 jiyarza
/**
11
 * This interface is the responsible of shared resources management.
12 28071 jmvivo
 *
13 24975 jiyarza
 * Allows getting a resource, iterating over the available resources, and
14
 * collecting resources to free them as they become unused
15
 *
16
 */
17 24268 jjdelcerro
public interface ResourceManager extends WeakReferencingObservable {
18 23894 jjdelcerro
        public Resource getResource(String name);
19 23754 jjdelcerro
20 24975 jiyarza
        /**
21
         * Returns an iterator over the available resources.
22 28071 jmvivo
         *
23 24975 jiyarza
         * @return
24
         *                 iterator over the resources.
25
         */
26 23894 jjdelcerro
        public Iterator iterator();
27 23754 jjdelcerro
28 24975 jiyarza
        /**
29 28484 jmvivo
         * 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 24975 jiyarza
         * @throws DataException
33 28484 jmvivo
         * @see {@link ResourceManager#getTimeToBeIdle()}
34
         *      {@link ResourceManager#setTimeToBeIdle(int)}
35 24975 jiyarza
         */
36 23894 jjdelcerro
        public void collectResources() throws DataException;
37 23754 jjdelcerro
38 24975 jiyarza
        /**
39 28484 jmvivo
         * 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 28071 jmvivo
         * Initializes the resource collection background process. Allows setting
63
         * of the delay between each execution of the collector and also an
64 24975 jiyarza
         * observer to be notified on each execution.
65 28071 jmvivo
         *
66 24975 jiyarza
         * @param milis
67
         *                         delay between each execution of the resource collection process, in milliseconds.
68 28071 jmvivo
         *
69 24975 jiyarza
         * @param observer
70
         *                         an observer that will be notified on each execution of the resource collection process.
71
         */
72 23894 jjdelcerro
        public void startResourceCollector(long milis, Observer observer);
73 23754 jjdelcerro
74 24975 jiyarza
        /**
75 28071 jmvivo
         * 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 24975 jiyarza
         */
78 23894 jjdelcerro
        public void stopResourceCollector();
79 23754 jjdelcerro
80 28071 jmvivo
        /**
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 23754 jjdelcerro
}