@@ -26,9 +26,6 @@ import org.modelix.model.IGenericKeyListener
26
26
import org.modelix.model.lazy.RepositoryId
27
27
import org.modelix.model.persistent.HashUtil
28
28
import org.modelix.model.server.SqlUtils
29
- import java.io.File
30
- import java.io.FileReader
31
- import java.io.IOException
32
29
import java.sql.SQLException
33
30
import java.util.*
34
31
import javax.cache.Cache
@@ -40,7 +37,9 @@ private val LOG = KotlinLogging.logger { }
40
37
* Store client implementation with an ignite cache.
41
38
* If [inmemory] is true, the data is not persisted in a database.
42
39
*/
43
- class IgniteStoreClient (jdbcConfFile : File ? = null , private val inmemory : Boolean = false ) : IsolatingStore, AutoCloseable {
40
+ class IgniteStoreClient (jdbcProperties : Properties ? = null , private val inmemory : Boolean = false ) :
41
+ IsolatingStore ,
42
+ AutoCloseable {
44
43
45
44
companion object {
46
45
private const val ENTRY_CHANGED_TOPIC = " entryChanged"
@@ -68,28 +67,14 @@ class IgniteStoreClient(jdbcConfFile: File? = null, private val inmemory: Boolea
68
67
* from ignite.xml is used
69
68
*/
70
69
init {
71
- if (jdbcConfFile != null ) {
70
+ if (jdbcProperties != null ) {
72
71
// Given that systemPropertiesMode is set to 2 (SYSTEM_PROPERTIES_MODE_OVERRIDE) in
73
72
// ignite.xml, we can override the properties through system properties
74
- try {
75
- val properties = Properties ()
76
- properties.load(FileReader (jdbcConfFile))
77
- for (pn in properties.stringPropertyNames()) {
78
- if (pn.startsWith(" jdbc." )) {
79
- System .setProperty(pn, properties.getProperty(pn))
80
- } else {
81
- throw RuntimeException (
82
- " Properties not related to jdbc are not permitted. Check file " +
83
- jdbcConfFile.absolutePath,
84
- )
85
- }
73
+ for (propertyName in jdbcProperties.stringPropertyNames()) {
74
+ require(propertyName.startsWith(" jdbc." )) {
75
+ " Property `$propertyName ` is invalid. Only properties starting with `jdbc.` are permitted."
86
76
}
87
- } catch (e: IOException ) {
88
- throw RuntimeException (
89
- " We are unable to load the JDBC configuration from " +
90
- jdbcConfFile.absolutePath,
91
- e,
92
- )
77
+ System .setProperty(propertyName, jdbcProperties.getProperty(propertyName))
93
78
}
94
79
}
95
80
if (! inmemory) updateDatabaseSchema()
0 commit comments