@Override public boolean isOpen() throws RepositoryException { RepositoryConnection conn = threadContext.get(); return conn != null && conn.isOpen(); } }
@Override public boolean isOpen() throws ModelRuntimeException { try { return this.connection != null && this.connection.isOpen(); } catch(RepositoryException e) { throw new ModelRuntimeException(e); } }
@Override public boolean isOpen() throws ModelRuntimeException { try { return connection != null && connection.isOpen(); } catch (RepositoryException e) { throw new ModelRuntimeException(e); } }
/** * Makes sure that the Connection to the wrapped Repository has been closed. */ @Override public void finalize() throws Throwable { try { if(this.connection.isOpen()) { this.logger.warn(this.getClass().getName() + " not closed, closing now."); close(); } } finally { super.finalize(); } }
/** * Makes sure that the Connection to the wrapped Repository has been closed. */ @Override public void finalize() throws Throwable { try { if (connection.isOpen()) { if( caller != null) { StringWriter sw = new StringWriter(); this.caller.printStackTrace( new PrintWriter(sw)); logger.warn(this.getClass().getName() + " not closed, closing now. Cause "+sw.getBuffer().toString()); } else { logger.warn(this.getClass().getName() + " not closed, closing now."); } close(); } } finally { super.finalize(); } }
/** * Closes a repository connection if it is open. Does nothing if it is * already closed. * * @param conn the connection to close * @throws WebApplicationException if there was a problem while closing the * connection */ protected void close(RepositoryConnection conn) { if (conn != null) { try { if (conn.isOpen()) { conn.close(); } } catch (RepositoryException ex) { throw new WebApplicationException(ex); } } }
/** * Closes a repository connection it it is open. Does nothing if it is * closed. If an exception occurs while closing the connection it will be * added as suppressed exception to the given exception. * * @param conn the connection to close * @param ex an exception that caused the closing of the connection */ protected void close(RepositoryConnection conn, Exception ex) { if (conn != null) { try { if (conn.isOpen()) { conn.close(); } } catch (RepositoryException ex2) { ex.addSuppressed(ex2); } } } }
@Override public RepositoryConnection getDelegate() throws RepositoryException { RepositoryConnection conn = threadContext.get(); if (conn == null || !conn.isOpen()) { conn = getRepository().getDelegate().getConnection(); threadContext.set(conn); } return conn; }
public RepositoryConnection getConn(){ if(conn==null && repository == null) return null; try { if(conn==null || !conn.isOpen()){ conn=repository.getConnection(); return conn; } } catch (RepositoryException e) { log.error(e.toString()); for(StackTraceElement s: e.getStackTrace()) log.error(s.toString()); return null; } return conn; } }
/** * Closes a connection if it is open. * * This method is intended to close a connection after an exception * occured. Any occuring exceptions while closing will be added as * suppressed exceptions to the given exception. * @param conn the connection that should be closed * @param ex an exception that caused the closing */ protected void close(RepositoryConnection conn, Exception ex) { if (conn != null) { try { if (conn.isOpen()) { conn.close(); } Repository rep = conn.getRepository(); } catch (RepositoryException ex2) { ex.addSuppressed(ex2); } } }
if (!connection.isOpen()) { throw new IllegalStateException("the connection is already closed, cannot access triple-store."); } if (!connection.isActive()) { throw new IllegalStateException("no active transaction, cannot access triple-store."); }
if (!connection.isOpen()) { throw new IllegalAccessException("the connection is already closed, cannot access proxy methods"); }
if (!connection.isOpen()) { throw new IllegalAccessException("the connection is already closed, cannot access proxy methods."); } if (!connection.isActive()) { throw new IllegalAccessException("no active transaction, cannot access triple-store."); }
@Test public void testMemoryRepository() throws RepositoryException { RepositoryConnection conn = repository.getConnection(); Assert.assertThat( "repository is open", conn.isOpen(), CoreMatchers.equalTo( true ) ); conn.close(); } }
@Test public void testNativeRepository() throws RepositoryException { RepositoryConnection conn = repository.getConnection(); Assert.assertThat("repository is open", conn.isOpen(), CoreMatchers.equalTo(true)); conn.close(); } }
if(conn != null && conn.isOpen())
if (FacadeUtils.isFacadeAnnotationPresent(type, RDFType.class)) { try { if (!connection.isOpen()) { throw new IllegalStateException("the connection is already closed, cannot access triple store."); } if (!connection.isActive()) { throw new IllegalStateException("no active transaction, cannot access triple-store."); }