Revision 47606 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultTransaction.java
DefaultTransaction.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.util.ArrayList; |
26 | 26 |
import java.util.HashMap; |
27 |
import java.util.HashSet; |
|
27 | 28 |
import java.util.List; |
28 | 29 |
import java.util.Map; |
30 |
import java.util.Set; |
|
29 | 31 |
import java.util.UUID; |
30 | 32 |
import org.apache.commons.lang3.StringUtils; |
31 | 33 |
import org.apache.commons.lang3.tuple.MutablePair; |
... | ... | |
62 | 64 |
private boolean inProgress; |
63 | 65 |
private List<Disposable> disposables; |
64 | 66 |
private ObservableHelper observableHelper; |
67 |
private Set<SupportTransactions> supportTransactions; |
|
65 | 68 |
|
66 | 69 |
public DefaultTransaction() { |
67 | 70 |
this.code = UUID.randomUUID().toString().replace("-", ""); |
68 | 71 |
this.stores = new HashMap<>(); |
69 | 72 |
this.explorers = new HashMap<>(); |
70 | 73 |
this.disposables = new ArrayList<>(); |
74 |
this.supportTransactions = new HashSet<>(); |
|
71 | 75 |
this.inProgress = false; |
72 | 76 |
this.connections = new HashMap<>(); |
73 | 77 |
this.observableHelper = new ObservableHelper(); |
... | ... | |
157 | 161 |
|
158 | 162 |
@Override |
159 | 163 |
public void add(DataStore store, String id, boolean local) { |
164 |
if(store == null){ |
|
165 |
throw new IllegalArgumentException("The store is required."); |
|
166 |
} |
|
160 | 167 |
String theId = id; |
161 | 168 |
if( StringUtils.isBlank(id) ) { |
162 | 169 |
theId = store.hashCode() + "@"+ store.getFullName(); |
... | ... | |
200 | 207 |
|
201 | 208 |
@Override |
202 | 209 |
public void add(DataServerExplorer explorer, String id, boolean local) { |
210 |
if(explorer == null){ |
|
211 |
throw new IllegalArgumentException("The explorer is required."); |
|
212 |
} |
|
203 | 213 |
String theId = id; |
204 | 214 |
if( StringUtils.isBlank(id) ) { |
205 | 215 |
theId = String.valueOf(explorer.hashCode()); |
... | ... | |
233 | 243 |
} |
234 | 244 |
|
235 | 245 |
@Override |
246 |
public void add(SupportTransactions obj, boolean local) throws DataException { |
|
247 |
if(obj == null){ |
|
248 |
throw new IllegalArgumentException("The transaction supplier is required."); |
|
249 |
} |
|
250 |
if(obj instanceof DataStore){ |
|
251 |
this.add((DataStore)obj, local); |
|
252 |
return; |
|
253 |
} |
|
254 |
if(obj instanceof DataServerExplorer){ |
|
255 |
this.add((DataServerExplorer)obj, local); |
|
256 |
return; |
|
257 |
} |
|
258 |
obj.setTransaction(this); |
|
259 |
if(!local){ |
|
260 |
DisposeUtils.bind(obj); |
|
261 |
} |
|
262 |
this.supportTransactions.add(obj); |
|
263 |
} |
|
264 |
|
|
265 |
@Override |
|
236 | 266 |
public void remove(DataStore store) { |
237 | 267 |
if( this.inProgress && !DisposeUtils.isNullOrDisposed(store)){ |
238 | 268 |
throw new IllegalStateException("Can't remove store from a in progress transaction."); |
... | ... | |
307 | 337 |
} |
308 | 338 |
DisposeUtils.disposeQuietly(resource); |
309 | 339 |
} |
340 |
for (SupportTransactions obj : supportTransactions) { |
|
341 |
obj.setTransaction(null); |
|
342 |
DisposeUtils.disposeQuietly(obj); |
|
343 |
} |
|
310 | 344 |
for (ConnectionService connection : this.connections.values()) { |
311 | 345 |
connection.dispose(); |
312 | 346 |
} |
347 |
this.supportTransactions = null; |
|
313 | 348 |
this.disposables = null; |
314 | 349 |
this.stores = null; |
315 | 350 |
} |
Also available in: Unified diff