View Javadoc
1   package com.github.davidmoten.rx.jdbc;
2   
3   import rx.Scheduler;
4   
5   /**
6    * The threading and database connection context for mutliple jdbc queries.
7    * 
8    */
9   final class QueryContext {
10  
11      private final Database db;
12  
13      /**
14       * Constructor.
15       * 
16       * @param executor
17       * @param connectionProvider
18       */
19      QueryContext(Database db) {
20          this.db = db;
21      }
22  
23      /**
24       * Returns the scheduler service to use to run queries with this context.
25       * 
26       * @return
27       */
28      Scheduler scheduler() {
29          return db.currentScheduler();
30      }
31  
32      /**
33       * Returns the connection provider for queries with this context.
34       * 
35       * @return
36       */
37      ConnectionProvider connectionProvider() {
38          return db.connectionProvider();
39      }
40  
41      void beginTransactionObserve() {
42          db.beginTransactionObserve();
43  
44      }
45  
46      void beginTransactionSubscribe() {
47          db.beginTransactionSubscribe();
48      }
49  
50      void endTransactionSubscribe() {
51          db.endTransactionSubscribe();
52      }
53  
54      void endTransactionObserve() {
55          db.endTransactionObserve();
56      }
57  
58  }