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