Revision 45481
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCServerExplorerBase.java | ||
---|---|---|
93 | 93 |
private static final Map<String, CachedValue<List<JDBCStoreParameters>>> CACHED_TABLES = Collections.synchronizedMap(new LRUMap(10)); |
94 | 94 |
|
95 | 95 |
|
96 |
private class CachedTablesValue extends CachedValue<List<JDBCStoreParameters>> { |
|
96 |
private static class CachedTablesValue extends CachedValue<List<JDBCStoreParameters>> {
|
|
97 | 97 |
|
98 | 98 |
private final int mode; |
99 | 99 |
private final JDBCServerExplorerParameters serverParameters; |
100 | 100 |
private final boolean informationTables; |
101 |
private final JDBCHelper helper; |
|
101 | 102 |
|
102 |
public CachedTablesValue(int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables) { |
|
103 |
public CachedTablesValue(JDBCHelper helper, int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables) {
|
|
103 | 104 |
this.mode = mode; |
104 | 105 |
this.serverParameters = serverParameters; |
105 | 106 |
this.informationTables = informationTables; |
107 |
this.helper = helper; |
|
106 | 108 |
} |
107 | 109 |
|
108 |
public CachedTablesValue(int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables, long expireTime) { |
|
110 |
public CachedTablesValue(JDBCHelper helper, int mode, JDBCServerExplorerParameters serverParameters, boolean informationTables, long expireTime) {
|
|
109 | 111 |
this.mode = mode; |
110 | 112 |
this.setExpireTime(expireTime); |
111 | 113 |
this.serverParameters = serverParameters; |
112 | 114 |
this.informationTables = informationTables; |
115 |
this.helper = helper; |
|
113 | 116 |
} |
114 | 117 |
|
115 | 118 |
@Override |
116 | 119 |
protected void reload() { |
117 | 120 |
List<JDBCStoreParameters> tables = null; |
121 |
OperationsFactory operations = helper.getOperations(); |
|
122 |
if(operations == null){ |
|
123 |
this.setValue(null); |
|
124 |
LOG.debug("Sets tables to null to force reload tables from new ServerExplorar."); |
|
125 |
return; |
|
126 |
} |
|
118 | 127 |
try { |
119 |
ListTablesOperation listTables = helper.getOperations().createListTables(
|
|
128 |
ListTablesOperation listTables = operations.createListTables(
|
|
120 | 129 |
this.mode, serverParameters, informationTables |
121 | 130 |
); |
122 | 131 |
tables = (List<JDBCStoreParameters>) listTables.perform(); |
123 | 132 |
} catch(Exception ex) { |
124 |
LOG.debug("Can't reload cached list of tables.",ex); |
|
133 |
LOG.debug("Can't reload cached list of tables.", ex);
|
|
125 | 134 |
} |
126 | 135 |
this.setValue(tables); |
127 | 136 |
} |
... | ... | |
198 | 207 |
if( tables != null ) { |
199 | 208 |
return tables; |
200 | 209 |
} |
201 |
tablesValue = new CachedTablesValue(mode, serverParams, informationTables, 60000); //60" |
|
210 |
tablesValue = new CachedTablesValue(this.helper, mode, serverParams, informationTables, 60000); //60"
|
|
202 | 211 |
CACHED_TABLES.put(key, tablesValue); |
203 | 212 |
tables = tablesValue.get(); |
204 | 213 |
return tables; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/JDBCHelperBase.java | ||
---|---|---|
26 | 26 |
import java.io.File; |
27 | 27 |
import java.sql.Blob; |
28 | 28 |
import java.sql.Clob; |
29 |
import org.gvsig.fmap.dal.store.jdbc2.impl.ResulSetControlerBase; |
|
30 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
31 | 29 |
import java.sql.Connection; |
32 | 30 |
import java.sql.ResultSet; |
33 | 31 |
import java.util.ArrayList; |
... | ... | |
39 | 37 |
import org.apache.commons.lang3.mutable.MutableBoolean; |
40 | 38 |
import org.gvsig.expressionevaluator.Code; |
41 | 39 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
42 |
import org.gvsig.expressionevaluator.ExpressionBuilder.ClassVisitorFilter; |
|
43 |
import org.gvsig.expressionevaluator.ExpressionBuilder.Variable; |
|
44 | 40 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
45 | 41 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
46 | 42 |
import org.gvsig.expressionevaluator.Function; |
... | ... | |
56 | 52 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
57 | 53 |
import org.gvsig.fmap.dal.feature.FeatureType; |
58 | 54 |
import org.gvsig.fmap.dal.feature.ForeingKey; |
59 |
|
|
60 | 55 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
61 | 56 |
import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase; |
62 | 57 |
import org.gvsig.fmap.dal.resource.exception.AccessResourceException; |
... | ... | |
80 | 75 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
81 | 76 |
import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler; |
82 | 77 |
import org.gvsig.fmap.dal.store.jdbc2.ResulSetControler.ResultSetEntry; |
78 |
import org.gvsig.fmap.dal.store.jdbc2.impl.ResulSetControlerBase; |
|
79 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
83 | 80 |
import org.gvsig.fmap.geom.Geometry; |
84 | 81 |
import org.gvsig.fmap.geom.GeometryLocator; |
85 | 82 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
330 | 327 |
|
331 | 328 |
@Override |
332 | 329 |
public OperationsFactory getOperations() { |
333 |
if (this.operationsFactory == null) { |
|
330 |
if (this.operationsFactory == null && !isClosed()) {
|
|
334 | 331 |
this.operationsFactory = new OperationsFactoryBase(this); |
335 | 332 |
} |
336 | 333 |
return operationsFactory; |
... | ... | |
411 | 408 |
|
412 | 409 |
@Override |
413 | 410 |
public void close() throws Exception { |
414 |
// this.resource.removeConsumer(this); |
|
415 | 411 |
JDBCUtils.closeQuietly(this.resulSetControler); |
416 |
// this.resource = null; |
|
417 | 412 |
this.resulSetControler = null; |
413 |
this.operationsFactory = null; |
|
414 |
this.srssolver = null; |
|
415 |
this.connectionParameters = null; |
|
416 |
this.helperClient = null; |
|
417 |
this.geometryManager = null; |
|
418 |
this.providerFeatureType = null; |
|
419 |
this.store = null; |
|
418 | 420 |
} |
421 |
|
|
422 |
public boolean isClosed() { |
|
423 |
return this.srssolver == null; |
|
424 |
} |
|
419 | 425 |
|
420 | 426 |
@Override |
421 | 427 |
public boolean closeResourceRequested(ResourceProvider resource) { |
Also available in: Unified diff