Package org.jboss.dna.graph.connector

Examples of org.jboss.dna.graph.connector.RepositoryConnection


    public void shouldAllowShutdownToBeCalledMultipleTimesEvenWhenShutdown()
        throws RepositorySourceException, InterruptedException {
        assertThat(pool.getTotalConnectionsCreated(), is(0l));
        assertThat(pool.getTotalConnectionsUsed(), is(0l));

        RepositoryConnection conn = pool.getConnection();
        assertThat(conn, is(notNullValue()));
        assertThat(pool.getTotalConnectionsCreated(), is(1l));
        assertThat(pool.getTotalConnectionsUsed(), is(1l));
        assertThat(pool.getPoolSize(), is(1));

        conn.close();

        assertThat(pool.getTotalConnectionsCreated(), is(1l));
        assertThat(pool.getTotalConnectionsUsed(), is(1l));
        assertThat(pool.getPoolSize(), is(1));
View Full Code Here


    @Test
    public void shouldAllowConnectionsToBeClosedMoreThanOnceWithNoIllEffects() throws RepositorySourceException {
        assertThat(pool.getTotalConnectionsCreated(), is(0l));
        assertThat(pool.getTotalConnectionsUsed(), is(0l));

        RepositoryConnection conn = pool.getConnection();
        assertThat(conn, is(notNullValue()));
        assertThat(pool.getTotalConnectionsCreated(), is(1l));
        assertThat(pool.getTotalConnectionsUsed(), is(1l));
        assertThat(pool.getPoolSize(), is(1));

        conn.close();
        conn.close();
    }
View Full Code Here

                              RepositoryOperation<T> operation ) throws RepositorySourceException, InterruptedException {
        CheckArg.isNotNull(operation, "repository operation");
        // Get a connection ...
        T result = null;
        LogContext.set("context", operation.getName());
        RepositoryConnection conn = pool.getConnection();
        try {
            // And run the client with the connection ...
            result = operation.run(context, conn);
        } finally {
            conn.close();
        }
        LogContext.clear();
        return result;
    }
View Full Code Here

            openConnections = new ArrayList<RepositoryConnection>();
            connectionFactory = new RepositoryConnectionFactory() {
                @SuppressWarnings( "synthetic-access" )
                public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
                    if (!source.getName().equals(sourceName)) return null;
                    RepositoryConnection connection = source.getConnection();
                    if (connection == null) {
                        throw new RepositorySourceException("Unable to create a repository connection to " + source.getName());
                    }
                    openConnections.add(connection);
                    return connection;
View Full Code Here

     * @throws RuntimeException if the request generated a runtime error
     * @throws RepositorySourceException if the request generated an error that was not a {@link RuntimeException}
     */
    protected <T extends Request> T execute( T request ) {
        // Get a connection ...
        RepositoryConnection connection = connectionFactory.createConnection(source.getName());
        try {
            connection.execute(context, request);
        } finally {
            connection.close();
        }
        if (request.hasError()) {
            Throwable error = request.getError();
            if (error instanceof RuntimeException) throw (RuntimeException)error;
            throw new RepositorySourceException(source.getName(), error);
View Full Code Here

    @Test
    public void shouldAllowMultipleConnectionsToBeOpenAtTheSameTime() throws Exception {
        List<RepositoryConnection> connections = new ArrayList<RepositoryConnection>();
        try {
            for (int i = 0; i != 10; ++i) {
                RepositoryConnection conn = source.getConnection();
                assertThat(conn, is(notNullValue()));
                connections.add(conn);
            }
        } finally {
            // Close all open connections ...
            for (RepositoryConnection conn : connections) {
                if (conn != null) {
                    try {
                        conn.close();
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.connector.RepositoryConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.