From e9866474aad253bfeeb3b5bb1bf8f14e2a481ec7 Mon Sep 17 00:00:00 2001 From: Robinson Date: Wed, 18 Aug 2021 17:58:05 -0600 Subject: [PATCH] Removed serialization manager --- LICENSE | 21 +++- README.md | 2 +- build.gradle.kts | 22 ++-- .../serializers/SerializationDefaults.kt | 7 +- .../serializers/SerializationManager.kt | 107 ------------------ 5 files changed, 36 insertions(+), 123 deletions(-) delete mode 100644 src/dorkbox/serializers/SerializationManager.kt diff --git a/LICENSE b/LICENSE index 5221402..dab84c9 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 9d5d0c7..c12cd20 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Maven Info com.dorkbox Serializers - 1.2 + 2.1 ``` diff --git a/build.gradle.kts b/build.gradle.kts index c72695d..e81f8e5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") } diff --git a/src/dorkbox/serializers/SerializationDefaults.kt b/src/dorkbox/serializers/SerializationDefaults.kt index 86fd723..93e6147 100644 --- a/src/dorkbox/serializers/SerializationDefaults.kt +++ b/src/dorkbox/serializers/SerializationDefaults.kt @@ -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. diff --git a/src/dorkbox/serializers/SerializationManager.kt b/src/dorkbox/serializers/SerializationManager.kt deleted file mode 100644 index 5c7b706..0000000 --- a/src/dorkbox/serializers/SerializationManager.kt +++ /dev/null @@ -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 { - /** - * 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 register(clazz: Class): 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 register(clazz: Class, 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 register(clazz: Class, serializer: Serializer): 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 register(clazz: Class, serializer: Serializer, 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? -}