Example #1
0
 @Override
 public ComposableFuture<QueryResult> sendQuery(final String query) {
   return ScalaFutureHelper.from(
       new ScalaFutureHelper.FutureProvider<QueryResult>() {
         @Override
         public Future<QueryResult> provide() {
           return _pool.sendQuery(query);
         }
       });
 }
Example #2
0
 @Override
 public ComposableFuture<QueryResult> sendPreparedStatement(
     final String query, final List<Object> values) {
   final Buffer<Object> scalaValues = JavaConversions.asScalaBuffer(values);
   return ScalaFutureHelper.from(
       new ScalaFutureHelper.FutureProvider<QueryResult>() {
         @Override
         public Future<QueryResult> provide() {
           return _pool.sendPreparedStatement(query, scalaValues);
         }
       });
 }
Example #3
0
 private ComposableFuture<Boolean> giveBack(final MySqlAsyncConnection conn) {
   return ScalaFutureHelper.from(
           new ScalaFutureHelper.FutureProvider<AsyncObjectPool<MySQLConnection>>() {
             @Override
             public Future<AsyncObjectPool<MySQLConnection>> provide() {
               return _pool.giveBack(conn.getInnerConnection());
             }
           })
       .continueWith(
           new ResultHandler<AsyncObjectPool<MySQLConnection>, Boolean>() {
             @Override
             public Boolean handle(final Try<AsyncObjectPool<MySQLConnection>> result) {
               return result.isSuccess();
             }
           });
 }
Example #4
0
  private ComposableFuture<MySqlAsyncConnection> take() {
    final ComposableFuture<MySQLConnection> connFuture =
        ScalaFutureHelper.from(
            new ScalaFutureHelper.FutureProvider<MySQLConnection>() {
              @Override
              public Future<MySQLConnection> provide() {
                return _pool.take();
              }
            });

    return connFuture.continueOnSuccess(
        new SuccessHandler<MySQLConnection, MySqlAsyncConnection>() {
          @Override
          public MySqlAsyncConnection handle(final MySQLConnection result) {
            return new MySqlAsyncConnection(result);
          }
        });
  }
Example #5
0
  @Override
  public ComposableFuture<Boolean> close() {
    final ComposableFuture<AsyncObjectPool<MySQLConnection>> future =
        ScalaFutureHelper.from(
            new ScalaFutureHelper.FutureProvider<AsyncObjectPool<MySQLConnection>>() {
              @Override
              public Future<AsyncObjectPool<MySQLConnection>> provide() {
                return _pool.close();
              }
            });

    return future.continueWith(
        new ResultHandler<AsyncObjectPool<MySQLConnection>, Boolean>() {
          @Override
          public Boolean handle(final Try<AsyncObjectPool<MySQLConnection>> result) {
            try {
              return result.isSuccess();
            } catch (final Exception e) {
              return false;
            }
          }
        });
  }