@Override public synchronized void close() { // close and dereference store if (store != null) { if (store.isOpen()) store.close(); store = null; } this.isopen = false; }
@Override protected void doRelease() throws ResourceException { if ((store != null) && (store.isOpen())) { store.close(); } }
@Override public synchronized void close() { // close and dereference store if (store != null) { if (store.isOpen()) store.close(); store = null; } this.isopen = false; }
throw e; } finally { if (store.isOpen()) store.close();
throw e; } finally { if (store.isOpen()) store.close();
@Override public synchronized void clear() throws IOException { // naive implementation that gets a store and clears it TopicMapStoreIF store = null; try { store = createStore(false); store.getTopicMap().clear(); } finally { if (store != null && store.isOpen()) store.close(); } }
throw t; } finally { if (store.isOpen()) store.close();
throw t; } finally { if (store.isOpen()) store.close();
throw t; } finally { if (store.isOpen()) store.close();
@Override public synchronized void storeClosed(TopicMapStoreIF store) { if (!store.isReadOnly()) { // dereference listeners ((AbstractTopicMapStore)store).setTopicListeners(null); } if (pool != null) { log.debug("RTR: return " + getId() + " i: " + pool.getNumIdle() + " a: " + pool.getNumActive()); try { // return rw store to pool if (!store.isReadOnly()) { pool.returnObject(store); } } catch (Exception e) { throw new OntopiaRuntimeException("Could not return topic map store '" + getId() + "' to pool.", e); } } else { // pool has been closed before store, so we should close store ourselves synchronized (store) { if (store.isOpen()) ((RDBMSTopicMapStore)store).close(false); } } }
/** * Tests that close and open update the status of the store appropriately. */ public void testOpenClose() { TopicMapStoreIF _store = factory.makeStandaloneTopicMapStore(); try { assertTrue("Store open", !_store.isOpen()); _store.open(); assertTrue("Store not open", _store.isOpen()); TopicMapIF tm1 = _store.getTopicMap(); _store.close(); assertTrue("Store not closed", !_store.isOpen()); try { TopicMapIF tm = _store.getTopicMap(); // Expected. _store.close(); } catch (StoreNotOpenException ex) { fail("Couldn't retrieve topic map [via TopicMapStoreIF.getTopicMap()] from a closed store!"); } _store.open(); assertTrue("Could not reopen store.", _store.isOpen()); } finally { _store.delete(true); } } }