Removed serialization manager

master
Robinson 2021-08-18 17:58:05 -06:00
parent 3a32ca7678
commit e9866474aa
5 changed files with 36 additions and 123 deletions

21
LICENSE
View File

@ -20,6 +20,12 @@
Kotlin Compiler, Test Data+Libraries, and Tools repository contain third-party code, to which different licenses may apply
See: https://github.com/JetBrains/kotlin/blob/master/license/README.md
- Bouncy Castle Crypto - Lightweight cryptography API and JCE Extension
[The Apache Software License, Version 2.0]
http://www.bouncycastle.org
Copyright 2021
The Legion of the Bouncy Castle Inc
- Kryo - Fast and efficient binary object graph serialization framework for Java
[BSD 3-Clause License]
https://github.com/EsotericSoftware/kryo
@ -42,8 +48,17 @@
https://github.com/EsotericSoftware/minlog
Nathan Sweet
- Bouncy Castle Crypto - Lightweight cryptography API and JCE Extension
- Updates - Software Update Management
[The Apache Software License, Version 2.0]
http://www.bouncycastle.org
https://git.dorkbox.com/dorkbox/Updates
Copyright 2021
The Legion of the Bouncy Castle Inc
Dorkbox LLC
Extra license information
- Kotlin -
[The Apache Software License, Version 2.0]
https://github.com/JetBrains/kotlin
Copyright 2020
JetBrains s.r.o. and Kotlin Programming Language contributors
Kotlin Compiler, Test Data+Libraries, and Tools repository contain third-party code, to which different licenses may apply
See: https://github.com/JetBrains/kotlin/blob/master/license/README.md

View File

@ -11,7 +11,7 @@ Maven Info
<dependency>
<groupId>com.dorkbox</groupId>
<artifactId>Serializers</artifactId>
<version>1.2</version>
<version>2.1</version>
</dependency>
</dependencies>
```

View File

@ -26,19 +26,19 @@ import java.time.Instant
gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS // always show the stacktrace!
plugins {
id("com.dorkbox.GradleUtils") version "2.8"
id("com.dorkbox.Licensing") version "2.7"
id("com.dorkbox.VersionUpdate") version "2.3"
id("com.dorkbox.GradleUtils") version "2.9"
id("com.dorkbox.Licensing") version "2.9.2"
id("com.dorkbox.VersionUpdate") version "2.4"
id("com.dorkbox.GradlePublish") version "1.11"
kotlin("jvm") version "1.5.0"
kotlin("jvm") version "1.5.21"
}
object Extras {
// set for the project
const val description = "Kryo based serializers"
const val group = "com.dorkbox"
const val version = "1.2"
const val version = "2.1"
// set as project.ext
const val name = "Serializers"
@ -99,14 +99,14 @@ tasks.jar.get().apply {
}
dependencies {
// listed as compile only, since we will be using kryo ANYWAYS if we use this project. **We don't want a hard dependency.**
compileOnly("com.esotericsoftware:kryo:5.1.1")
implementation("com.dorkbox:Updates:1.1")
// listed as compile only, since we will be using bouncy castle ANYWAYS if we use this project. **We don't want a hard dependency.**
compileOnly("org.bouncycastle:bcprov-jdk15on:1.68")
implementation("com.esotericsoftware:kryo:5.2.0")
testImplementation("com.esotericsoftware:kryo:5.1.1")
testImplementation("org.bouncycastle:bcprov-jdk15on:1.68")
// listed as compile only, since we will be optionally be using bouncy castle if we use this project. **We don't want a hard dependency.**
compileOnly("org.bouncycastle:bcprov-jdk15on:1.69")
testImplementation("org.bouncycastle:bcprov-jdk15on:1.69")
testImplementation("junit:junit:4.13.2")
}

View File

@ -26,7 +26,12 @@ object SerializationDefaults {
/**
* Gets the version number.
*/
const val version = "1.2"
const val version = "2.1"
init {
// Add this project to the updates system, which verifies this class + UUID + version information
dorkbox.updates.Updates.add(SerializationDefaults::class.java, "316353f5338341a8a3edc01d702703f8", version)
}
/**
* Allows for the kryo registration of sensible defaults in a common, well-used way.

View File

@ -1,107 +0,0 @@
/*
* Copyright 2021 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.serializers
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import java.io.IOException
interface SerializationManager<IO> {
/**
* Registers the class using the lowest, next available integer ID and the [default serializer][Kryo.getDefaultSerializer].
* If the class is already registered, the existing entry is updated with the new serializer.
*
*
* Registering a primitive also affects the corresponding primitive wrapper.
*
*
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when using this
* method. The order must be the same at deserialization as it was for serialization.
*/
fun <T> register(clazz: Class<T>): SerializationManager<*>
/**
* Registers the class using the specified ID. If the ID is already in use by the same type, the old entry is overwritten. If the ID
* is already in use by a different type, a [KryoException] is thrown.
*
*
* Registering a primitive also affects the corresponding primitive wrapper.
*
*
* IDs must be the same at deserialization as they were for serialization.
*
* @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and String, but
* these IDs can be repurposed.
*/
fun <T> register(clazz: Class<T>, id: Int): SerializationManager<*>
/**
* Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already registered,
* the existing entry is updated with the new serializer.
*
*
* Registering a primitive also affects the corresponding primitive wrapper.
*
*
* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when using this
* method. The order must be the same at deserialization as it was for serialization.
*/
fun <T> register(clazz: Class<T>, serializer: Serializer<T>): SerializationManager<*>
/**
* Registers the class using the specified ID and serializer. If the ID is already in use by the same type, the old entry is
* overwritten. If the ID is already in use by a different type, a [KryoException] is thrown.
*
*
* Registering a primitive also affects the corresponding primitive wrapper.
*
*
* IDs must be the same at deserialization as they were for serialization.
*
* @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and String, but
* these IDs can be repurposed.
*/
fun <T> register(clazz: Class<T>, serializer: Serializer<T>, id: Int): SerializationManager<*>
/**
* Waits until a kryo is available to write, using CAS operations to prevent having to synchronize.
*
* There is a small speed penalty if there were no kryo's available to use.
*/
@Throws(IOException::class)
fun write(buffer: IO, message: Any?)
/**
* Reads an object from the buffer.
*
* @param length should ALWAYS be the length of the expected object!
*/
@Throws(IOException::class)
fun read(buffer: IO, length: Int): Any?
/**
* Writes the class and object using an available kryo instance
*/
@Throws(IOException::class)
fun writeFullClassAndObject(output: Output, value: Any?)
/**
* Returns a class read from the input
*/
@Throws(IOException::class)
fun readFullClassAndObject(input: Input): Any?
}