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 @ 47080
History | View | Annotate | Download (3.58 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.dal.resource; |
25 |
|
26 |
import java.util.Iterator; |
27 |
|
28 |
import org.gvsig.fmap.dal.exception.DataException; |
29 |
import org.gvsig.fmap.dal.resource.exception.DisposeResorceManagerException; |
30 |
import org.gvsig.tools.observer.Observer; |
31 |
import org.gvsig.tools.observer.WeakReferencingObservable; |
32 |
|
33 |
/**
|
34 |
* This interface is the responsible of shared resources management.
|
35 |
*
|
36 |
* Allows getting a resource, iterating over the available resources, and
|
37 |
* collecting resources to free them as they become unused
|
38 |
*
|
39 |
*/
|
40 |
public interface ResourceManager extends WeakReferencingObservable, Iterable<Resource> { |
41 |
public Resource getResource(String name); |
42 |
|
43 |
/**
|
44 |
* Returns an iterator over the available resources.
|
45 |
*
|
46 |
* @return
|
47 |
* iterator over the resources.
|
48 |
*/
|
49 |
public Iterator<Resource> iterator(); |
50 |
|
51 |
/**
|
52 |
* Iterates over the resources and frees them if they are ready to be freed
|
53 |
* or try to close them if they are idle.
|
54 |
*
|
55 |
* @throws DataException
|
56 |
* @see {@link ResourceManager#getTimeToBeIdle()}
|
57 |
* {@link ResourceManager#setTimeToBeIdle(int)}
|
58 |
*/
|
59 |
public void collectResources() throws DataException; |
60 |
|
61 |
/**
|
62 |
* Returns the wait time to consider that a resource is idle in seconds.
|
63 |
* Used in collect resouces action. <br>
|
64 |
* if is lower than 1 never is idle.
|
65 |
*
|
66 |
* @return seconds
|
67 |
*
|
68 |
* @see {@link ResourceManager#collectResources()}
|
69 |
* @see {@link ResourceManager#startResourceCollector(long, Observer)}
|
70 |
*/
|
71 |
public int getTimeToBeIdle(); |
72 |
|
73 |
/**
|
74 |
* Sets the wait time to consider that a resource is idle. Used in collect
|
75 |
* resouces action. <br>
|
76 |
* if is lower than 1 never is idle.
|
77 |
*
|
78 |
* @see {@link ResourceManager#collectResources()}
|
79 |
* @see {@link ResourceManager#startResourceCollector(long, Observer)}
|
80 |
*/
|
81 |
|
82 |
public void setTimeToBeIdle(int seconds); |
83 |
|
84 |
/**
|
85 |
* Initializes the resource collection background process. Allows setting
|
86 |
* of the delay between each execution of the collector and also an
|
87 |
* observer to be notified on each execution.
|
88 |
*
|
89 |
* @param milis
|
90 |
* delay between each execution of the resource collection process, in milliseconds.
|
91 |
*
|
92 |
* @param observer
|
93 |
* an observer that will be notified on each execution of the resource collection process.
|
94 |
*/
|
95 |
public void startResourceCollector(long milis, Observer observer); |
96 |
|
97 |
/**
|
98 |
* Stops successive executions of the resource collector process. It does not interrupt
|
99 |
* the process if it is currently running, but it will not be executed anymore times.
|
100 |
*/
|
101 |
public void stopResourceCollector(); |
102 |
|
103 |
/**
|
104 |
* Close all register resources.
|
105 |
*
|
106 |
* @throws DataException
|
107 |
*/
|
108 |
public void closeResources() throws DataException; |
109 |
|
110 |
public void dispose() throws DisposeResorceManagerException; |
111 |
|
112 |
} |