Tweaked how the settingsStore types are registered with kryo
This commit is contained in:
parent
202b201a81
commit
f1fec705b9
|
@ -237,12 +237,14 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
|
|||
settingsStore = config.settingsStore
|
||||
settingsStore.init(serialization, config.settingsStorageSystem.build())
|
||||
|
||||
settingsStore.getSerializationTypes().forEach {
|
||||
serialization.register(it)
|
||||
}
|
||||
|
||||
crypto = CryptoManagement(logger, settingsStore, type, config)
|
||||
|
||||
// we are done with initial configuration, now finish serialization
|
||||
runBlocking {
|
||||
serialization.finishInit(type)
|
||||
}
|
||||
serialization.finishInit(type)
|
||||
}
|
||||
|
||||
internal suspend fun initEndpointState(): Aeron {
|
||||
|
|
|
@ -17,11 +17,9 @@ package dorkbox.network.storage
|
|||
|
||||
import dorkbox.network.connection.CryptoManagement
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import dorkbox.util.bytes.ByteArrayWrapper
|
||||
import dorkbox.util.storage.Storage
|
||||
import org.agrona.collections.Int2ObjectHashMap
|
||||
import java.security.SecureRandom
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* The property store is the DEFAULT type of store for the network stack.
|
||||
|
@ -36,15 +34,6 @@ class PropertyStore : SettingsStore() {
|
|||
* @param serializationManager this is the serialization used for saving objects into the storage database
|
||||
*/
|
||||
override fun init(serializationManager: Serialization, storage: Storage) {
|
||||
// make sure our custom types are registered
|
||||
// only register if not ALREADY initialized, since we can initialize in the server and in the client. This creates problems if
|
||||
// running inside the same JVM (we don't permit it)
|
||||
if (!serializationManager.initialized()) {
|
||||
serializationManager.register(HashMap::class.java)
|
||||
serializationManager.register(ByteArrayWrapper::class.java)
|
||||
serializationManager.register(DB_Server::class.java)
|
||||
}
|
||||
|
||||
this.storage = storage
|
||||
servers = this.storage.get(DB_Server.STORAGE_KEY, Int2ObjectHashMap())
|
||||
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
package dorkbox.network.storage
|
||||
|
||||
import dorkbox.network.serialization.Serialization
|
||||
import dorkbox.util.bytes.ByteArrayWrapper
|
||||
import dorkbox.util.exceptions.SecurityException
|
||||
import dorkbox.util.storage.Storage
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* This class provides a way for the network stack to use the server's database, instead of a property file (which it uses when stand-alone)
|
||||
|
@ -32,6 +34,16 @@ abstract class SettingsStore : AutoCloseable {
|
|||
*/
|
||||
abstract fun init(serializationManager: Serialization, storage: Storage)
|
||||
|
||||
fun getSerializationTypes(): List<Class<out Any>> {
|
||||
// make sure our custom types are registered
|
||||
// only register if not ALREADY initialized, since we can initialize in the server and in the client. This creates problems if
|
||||
// running inside the same JVM
|
||||
return listOf(HashMap::class.java,
|
||||
ByteArrayWrapper::class.java,
|
||||
DB_Server::class.java
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple, property based method for saving the private key of the server
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user