Revision 45156 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
JDBCServerExplorerBase.java | ||
---|---|---|
90 | 90 |
|
91 | 91 |
private Boolean canAdd; |
92 | 92 |
|
93 |
private static final Map<String, CachedValue<List<JDBCStoreParameters>>> cachedTables = Collections.synchronizedMap(new LRUMap(10));
|
|
93 |
private static final Map<String, CachedValue<List<JDBCStoreParameters>>> CACHED_TABLES = Collections.synchronizedMap(new LRUMap(10));
|
|
94 | 94 |
|
95 | 95 |
|
96 | 96 |
private class CachedTablesValue extends CachedValue<List<JDBCStoreParameters>> { |
... | ... | |
114 | 114 |
|
115 | 115 |
@Override |
116 | 116 |
protected void reload() { |
117 |
|
|
118 |
ListTablesOperation listTables = getOperations().createListTables( |
|
119 |
this.mode, baseParams, informationTables |
|
120 |
); |
|
121 |
List<JDBCStoreParameters> tables = (List<JDBCStoreParameters>) listTables.perform(); |
|
117 |
List<JDBCStoreParameters> tables = null; |
|
118 |
try { |
|
119 |
ListTablesOperation listTables = helper.getOperations().createListTables( |
|
120 |
this.mode, baseParams, informationTables |
|
121 |
); |
|
122 |
tables = (List<JDBCStoreParameters>) listTables.perform(); |
|
123 |
} catch(Exception ex) { |
|
124 |
LOG.debug("Can't reload cached list of tables.",ex); |
|
125 |
} |
|
122 | 126 |
this.setValue(tables); |
123 | 127 |
} |
124 | 128 |
} |
... | ... | |
186 | 190 |
JDBCStoreParameters baseParams = this.getOpenParameters(); |
187 | 191 |
|
188 | 192 |
String key = buildKeyForCachedTables(mode, baseParams, informationTables); |
189 |
CachedValue<List<JDBCStoreParameters>> tablesValue = cachedTables.get(key); |
|
190 |
if(tablesValue == null){ |
|
191 |
tablesValue = new CachedTablesValue(mode, baseParams, informationTables, 60000); //60" |
|
192 |
|
|
193 |
cachedTables.put(key, tablesValue); |
|
193 |
CachedValue<List<JDBCStoreParameters>> tablesValue = CACHED_TABLES.get(key); |
|
194 |
List<JDBCStoreParameters> tables = null; |
|
195 |
if(tablesValue != null){ |
|
196 |
tables = tablesValue.get(); |
|
194 | 197 |
} |
195 |
|
|
196 |
return tablesValue.get(); |
|
198 |
if( tables != null ) { |
|
199 |
return tables; |
|
200 |
} |
|
201 |
tablesValue = new CachedTablesValue(mode, baseParams, informationTables, 60000); //60" |
|
202 |
CACHED_TABLES.put(key, tablesValue); |
|
203 |
tables = tablesValue.get(); |
|
204 |
return tables; |
|
197 | 205 |
} |
198 | 206 |
|
199 | 207 |
public String buildKeyForCachedTables(int mode, JDBCStoreParameters params, boolean informationTables) { |
... | ... | |
220 | 228 |
boolean informationTables = BooleanUtils.isTrue( |
221 | 229 |
this.getParameters().getShowInformationDBTables() |
222 | 230 |
); |
223 |
cachedTables.remove(buildKeyForCachedTables(MODE_ALL, params, informationTables));
|
|
224 |
cachedTables.remove(buildKeyForCachedTables(MODE_FEATURE, params, informationTables));
|
|
225 |
cachedTables.remove(buildKeyForCachedTables(MODE_GEOMETRY, params, informationTables));
|
|
231 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_ALL, params, informationTables));
|
|
232 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_FEATURE, params, informationTables));
|
|
233 |
CACHED_TABLES.remove(buildKeyForCachedTables(MODE_GEOMETRY, params, informationTables));
|
|
226 | 234 |
} |
227 | 235 |
} |
228 | 236 |
|
Also available in: Unified diff