@@ -7,22 +7,6 @@ import scala.concurrent._
7
7
import org .springframework .transaction .PlatformTransactionManager
8
8
9
9
object Database {
10
- /**
11
- * Create a new Database. Sessions created by this database will manage their own transaction semantics.
12
- *
13
- * Note - if this datasource is synchronized to a Spring PlatformTransactionManager, usage of a Database returned from
14
- * this method will interfere with and likely cause undefined behavior with Spring managed transactions.
15
- */
16
- def apply (ds : DataSource ) = new JdbcDatabase (ds)
17
-
18
- /**
19
- * Create a new Database that will create and participate in Spring managed transactions.
20
- *
21
- * Note - the supplied DataSource *MUST* be synchronized by the supplied PlatformTransactionManager,
22
- * or undefined (and likely destructive) behavior will occur.
23
- */
24
- def apply (ds : DataSource , txManager : PlatformTransactionManager ) = new SpringDatabase (ds, txManager)
25
-
26
10
private val logger = LoggerFactory .getLogger(classOf [Database ])
27
11
}
28
12
@@ -61,10 +45,21 @@ trait Database {
61
45
62
46
}
63
47
64
- private [janus] class JdbcDatabase (ds : DataSource ) extends Database {
48
+ /**
49
+ * A plain Database implementation that does it's own transaction management.
50
+ *
51
+ */
52
+ class JdbcDatabase (ds : DataSource ) extends Database {
65
53
def createSession : Session = new SimpleSession (ds)
66
54
}
67
55
68
- private [janus] class SpringDatabase (ds : DataSource , txManager : PlatformTransactionManager ) extends Database {
56
+ /**
57
+ * A Database that can participate in Spring managed transactions. This Database will delegate all transaction
58
+ * semantics to Spring, and is capable of creating and participating in a thread-bound transaction context.
59
+ *
60
+ * IMPORTANT - The supplied DataSource *MUST* be synchronized by the provided PlatformTransactionManager. If it is not,
61
+ * undefined (and likely destructive) behavior will occur.
62
+ */
63
+ class SpringDatabase (ds : DataSource , txManager : PlatformTransactionManager ) extends Database {
69
64
def createSession : Session = new SpringSession (ds, txManager)
70
65
}
0 commit comments