📄 data.java
字号:
}
/**
* Release all feature locks currently held.
*
* <p>
* This is the implementation for the Admin "free lock" action, transaction
* locks are not released.
* </p>
*
* @return Number of locks released
*/
public synchronized int lockReleaseAll() {
int count = 0;
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
} catch (Throwable huh) {
continue; // not even working
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
// TODO: implement LockingManger.releaseAll()
// count += lockingManager.releaseAll();
}
return count;
}
/**
* Release lock by authorization
*
* @param lockID
*/
public synchronized void lockRelease(String lockID) {
boolean refresh = false;
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
Transaction t = new DefaultTransaction("Refresh " + meta.getNameSpace());
try {
t.addAuthorization(lockID);
if (lockingManager.release(lockID, t)) {
refresh = true;
}
} catch (IOException e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, e.getMessage(), e);
}
} finally {
try {
t.close();
} catch (IOException closeException) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, closeException.getMessage(), closeException);
}
}
}
}
if (!refresh) {
// throw exception? or ignore...
}
}
/**
* Refresh lock by authorization
*
* <p>
* Should use your own transaction?
* </p>
*
* @param lockID
*/
public synchronized void lockRefresh(String lockID) {
boolean refresh = false;
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
Transaction t = new DefaultTransaction("Refresh " + meta.getNameSpace());
try {
t.addAuthorization(lockID);
if (lockingManager.refresh(lockID, t)) {
refresh = true;
}
} catch (IOException e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, e.getMessage(), e);
}
} finally {
try {
t.close();
} catch (IOException closeException) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, closeException.getMessage(), closeException);
}
}
}
}
if (!refresh) {
// throw exception? or ignore...
}
}
/**
* Implement lockRefresh.
*
* @param lockID
* @param t
*
* @return true if lock was found and refreshed
*
* @throws IOException
*
* @see org.geotools.data.Data#lockRefresh(java.lang.String,
* org.geotools.data.Transaction)
*/
public synchronized boolean lockRefresh(String lockID, Transaction t)
throws IOException {
boolean refresh = false;
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
if (lockingManager.refresh(lockID, t)) {
refresh = true;
}
}
return refresh;
}
/**
* Implement lockRelease.
*
* @param lockID
* @param t
*
* @return true if the lock was found and released
*
* @throws IOException
*
* @see org.geotools.data.Data#lockRelease(java.lang.String,
* org.geotools.data.Transaction)
*/
public synchronized boolean lockRelease(String lockID, Transaction t)
throws IOException {
boolean release = false;
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
if (lockingManager.release(lockID, t)) {
release = true;
}
}
return release;
}
/**
* Implement lockExists.
*
* @param lockID
*
* @return true if lockID exists
*
* @see org.geotools.data.Data#lockExists(java.lang.String)
*/
public synchronized boolean lockExists(String lockID) {
for (Iterator i = dataStores.values().iterator(); i.hasNext();) {
DataStoreInfo meta = (DataStoreInfo) i.next();
if (!meta.isEnabled()) {
continue; // disabled
}
DataStore dataStore;
try {
dataStore = meta.getDataStore();
} catch (IllegalStateException notAvailable) {
continue; // not available
}
LockingManager lockingManager = dataStore.getLockingManager();
if (lockingManager == null) {
continue; // locks not supported
}
if (lockingManager.exists(lockID)) {
return true;
}
}
return false;
}
//
// GeoTools2 Catalog API
//
/**
* Set of available Namespace prefixes.
*
* @return Set of namespace Prefixes
*
* @see org.geotools.data.Catalog#getPrefixes()
*/
public synchronized Set getPrefixes() {
return Collections.unmodifiableSet(nameSpaces.keySet());
}
/**
* Prefix of the defaultNamespace.
*
* @return prefix of the default namespace
*
* @see org.geotools.data.Catalog#getDefaultPrefix()
*/
public synchronized String getDefaultPrefix() {
return defaultNameSpace.getPrefix();
}
/**
* Implement getNamespace.
*
* <p>
* Description ...
* </p>
*
* @param prefix
*
* @return
*
* @see org.geotools.data.Catalog#getNamespace(java.lang.String)
*/
public synchronized NameSpaceInfo getNamespaceMetaData(String prefix) {
return getNameSpace(prefix);
}
/**
* Register a DataStore with this Catalog.
*
* <p>
* This is part of the public CatalogAPI, the fact that we don't want to
* support it here may be gounds for it's removal.
* </p>
*
* <p>
* GeoSever and the global package would really like to have <b>complete</b>
* control over the DataStores in use by the application. It recognize that
* this may not always be possible. As GeoServer is extend with additional
* Modules (such as config) that wish to locate and talk to DataStores
* independently of GeoServer the best we can do is ask them to register
* with the this Catalog in global.
* </p>
*
* <p>
* This reveals what may be a deisgn flaw in GeoTools2 DataStore. We have
* know way of knowing if the dataStore has already been placed into our
* care as DataStores are not good at identifying themselves. To complicate
* matters most keep a static connectionPool around in their GDSFactory - it
* could be that the Factories are supposed to be smart enough to prevent
* duplication.
* </p>
*
* @param dataStore
*
* @throws IOException
*
* @see org.geotools.data.Catalog#registerDataStore(org.geotools.data.DataStore)
*/
public sy
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -