private JdbcConnectionAccess buildLocalConnectionAccess() { return new JdbcConnectionAccess() { @Override public Connection obtainConnection() throws SQLException { return settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE ? serviceRegistry .getService(ConnectionProvider.class).getConnection() : serviceRegistry.getService( MultiTenantConnectionProvider.class) .getAnyConnection(); } @Override public void releaseConnection(Connection connection) throws SQLException { if (settings.getMultiTenancyStrategy() == MultiTenancyStrategy.NONE) { serviceRegistry.getService(ConnectionProvider.class) .closeConnection(connection); } else { serviceRegistry.getService( MultiTenantConnectionProvider.class) .releaseAnyConnection(connection); } } @Override public boolean supportsAggressiveRelease() { return false; } }; }