Revision 28484

View differences:

branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/impl/DefaultResourceManager.java
45 45
	private Timer timer = null;
46 46
	private Logger logger;
47 47

  
48
	private long mlsecondsToBeIdle = 0;
49

  
48 50
	public DefaultResourceManager() {
49 51
		/*
50 52
		 * Create te extensions point in te registry.
......
112 114
			key = (String) iter.next();
113 115
			res = (ResourceProvider) this.resources.get(key);
114 116
			if (res.getConsumersCount() < 1) {
117
				res.closeRequest();
115 118
				res.notifyDispose();
116 119
				iter.remove();
120
				continue;
117 121
			}
122
			if (mlsecondsToBeIdle > 0
123
					&& System.currentTimeMillis()
124
							- res.getLastTimeUsed().getTime() > mlsecondsToBeIdle) {
118 125

  
126
			}
127

  
119 128
		}
120 129
	}
121 130

  
......
316 325
		}
317 326
	}
318 327

  
328
	public int getTimeToBeIdle() {
329
		if (mlsecondsToBeIdle == 0) {
330
			return 0;
331
		}
332
		return (int) (mlsecondsToBeIdle / 1000);
333
	}
334

  
335
	public void setTimeToBeIdle(int seconds) {
336
		if (seconds < 0) {
337
			throw new IllegalArgumentException("seconds must be >= 0");
338
		}
339
		mlsecondsToBeIdle = seconds * 1000;
340
	}
341

  
319 342
}
branches/v2_0_0_prep/libraries/libFMap_dal/src/org/gvsig/fmap/dal/resource/ResourceManager.java
26 26
	public Iterator iterator();
27 27

  
28 28
	/**
29
	 * Iterates over the resources and frees them if they are ready to
30
	 * be freed.
31
	 *
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 32
	 * @throws DataException
33
	 * @see {@link ResourceManager#getTimeToBeIdle()}
34
	 *      {@link ResourceManager#setTimeToBeIdle(int)}
33 35
	 */
34 36
	public void collectResources() throws DataException;
35 37

  
36 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
	/**
37 62
	 * Initializes the resource collection background process. Allows setting
38 63
	 * of the delay between each execution of the collector and also an
39 64
	 * observer to be notified on each execution.

Also available in: Unified diff