-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added serializers to fix bean-def kryozation
- Loading branch information
Holger Brandl
committed
Nov 9, 2021
1 parent
dccc1e6
commit b8152c6
Showing
5 changed files
with
135 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import com.esotericsoftware.kryo.io.Input | ||
import com.esotericsoftware.kryo.io.Output | ||
import org.koin.core.Koin | ||
import org.koin.core.context.GlobalContext | ||
import org.koin.dsl.module | ||
import java.awt.Dimension | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.io.FileOutputStream | ||
|
||
fun main() { | ||
val saveFile = File("file.bin") | ||
val kryo = buildKryo() | ||
|
||
val koin = GlobalContext.startKoin {}.koin | ||
|
||
koin. loadModules(listOf( | ||
module(createdAtStart = true) { | ||
single { Dimension(23,3) } | ||
} | ||
)) | ||
|
||
val output = Output(FileOutputStream(saveFile)) | ||
kryo.writeClassAndObject(output, koin) | ||
output.close() | ||
|
||
// the downstream bits here do not matter, because it fails already while saving | ||
|
||
println("restoring...") | ||
val input = Input(FileInputStream(saveFile)); | ||
val restored = kryo.readClassAndObject(input) as Koin | ||
|
||
val result = restored.get<Dimension>() | ||
println("result is ${result}") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters