svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / test / java / org / gvsig / fmap / dal / feature / testmulithread / DeleteLastFeature.java @ 40596
History | View | Annotate | Download (2.59 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.feature.testmulithread; |
25 |
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
27 |
import org.gvsig.fmap.dal.exception.DataRuntimeException; |
28 |
import org.gvsig.tools.dispose.DisposableIterator; |
29 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
30 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
31 |
import org.gvsig.fmap.dal.feature.exception.ConcurrentDataModificationException; |
32 |
|
33 |
/**
|
34 |
* @author jmvivo
|
35 |
*
|
36 |
*/
|
37 |
public class DeleteLastFeature extends StoreTask { |
38 |
|
39 |
/**
|
40 |
* @param store
|
41 |
* @param timeToWait
|
42 |
*/
|
43 |
public DeleteLastFeature(String id, FeatureStore store) { |
44 |
super(id, store);
|
45 |
} |
46 |
|
47 |
/**
|
48 |
* @param store
|
49 |
* @param timeToWait
|
50 |
*/
|
51 |
public DeleteLastFeature(String id, FeatureStore store, int timeToWait) { |
52 |
super(id, store, timeToWait);
|
53 |
} |
54 |
|
55 |
public void run() { |
56 |
if (!this.startProcess()) { |
57 |
return;
|
58 |
} |
59 |
FeatureSet set; |
60 |
DisposableIterator iter = null;
|
61 |
try {
|
62 |
set = this.store.getFeatureSet();
|
63 |
} catch (DataException e) {
|
64 |
finishedError(e); |
65 |
return;
|
66 |
} |
67 |
try {
|
68 |
|
69 |
try {
|
70 |
iter = set.iterator(); |
71 |
while (iter.hasNext()) {
|
72 |
iter.next(); |
73 |
} |
74 |
} catch (ConcurrentDataModificationException e) {
|
75 |
finishedConcurrentError(e); |
76 |
return;
|
77 |
} catch (DataException e) {
|
78 |
finishedError(e); |
79 |
return;
|
80 |
} |
81 |
try {
|
82 |
|
83 |
iter.remove(); |
84 |
} catch (DataRuntimeException e) {
|
85 |
if (e.getCause() instanceof ConcurrentDataModificationException) { |
86 |
finishedConcurrentError(e); |
87 |
return;
|
88 |
} |
89 |
finishedError(e); |
90 |
return;
|
91 |
|
92 |
} catch (RuntimeException e) { |
93 |
finishedError(e); |
94 |
return;
|
95 |
} |
96 |
finishedOk(); |
97 |
} catch (Throwable e) { |
98 |
finishedError(e); |
99 |
return;
|
100 |
} finally {
|
101 |
iter.dispose(); |
102 |
set.dispose(); |
103 |
} |
104 |
} |
105 |
|
106 |
|
107 |
} |