From b96ac4be89915ce7c414885348ca4915f2997673 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 22 Jan 2018 15:14:15 +0100 Subject: [PATCH] Added more methods to Serialization. Updated package names --- .../serialization/IgnoreSerialization.java | 29 ------------------- .../SerializationManager.java | 22 +++++++------- .../UnmodifiableCollectionsSerializer.java | 2 -- .../DefaultStorageSerializationManager.java | 9 +++++- src/dorkbox/util/storage/DiskStorage.java | 2 +- src/dorkbox/util/storage/Metadata.java | 2 +- src/dorkbox/util/storage/StorageBase.java | 2 +- src/dorkbox/util/storage/StorageSystem.java | 2 +- 8 files changed, 23 insertions(+), 47 deletions(-) delete mode 100644 src/dorkbox/util/serialization/IgnoreSerialization.java rename src/dorkbox/util/{ => serialization}/SerializationManager.java (87%) diff --git a/src/dorkbox/util/serialization/IgnoreSerialization.java b/src/dorkbox/util/serialization/IgnoreSerialization.java deleted file mode 100644 index 9a49fa9..0000000 --- a/src/dorkbox/util/serialization/IgnoreSerialization.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010 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.util.serialization; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Used to identify fields that kryo should ignore when configured with the FieldAnnotationAwareSerializer - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public -@interface IgnoreSerialization {} diff --git a/src/dorkbox/util/SerializationManager.java b/src/dorkbox/util/serialization/SerializationManager.java similarity index 87% rename from src/dorkbox/util/SerializationManager.java rename to src/dorkbox/util/serialization/SerializationManager.java index bd3311e..0f6e212 100644 --- a/src/dorkbox/util/SerializationManager.java +++ b/src/dorkbox/util/serialization/SerializationManager.java @@ -1,19 +1,19 @@ /* - * Copyright 2010 dorkbox, llc + * Copyright 2018 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 + * 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 + * 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. + * 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.util; +package dorkbox.util.serialization; import java.io.IOException; diff --git a/src/dorkbox/util/serialization/UnmodifiableCollectionsSerializer.java b/src/dorkbox/util/serialization/UnmodifiableCollectionsSerializer.java index 61b0b3b..e9c1cde 100644 --- a/src/dorkbox/util/serialization/UnmodifiableCollectionsSerializer.java +++ b/src/dorkbox/util/serialization/UnmodifiableCollectionsSerializer.java @@ -37,8 +37,6 @@ import com.esotericsoftware.kryo.Serializer; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; -import dorkbox.util.SerializationManager; - /** * A kryo {@link Serializer} for unmodifiable {@link Collection}s and {@link Map}s * created via {@link Collections}. diff --git a/src/dorkbox/util/storage/DefaultStorageSerializationManager.java b/src/dorkbox/util/storage/DefaultStorageSerializationManager.java index 1883810..01d0456 100644 --- a/src/dorkbox/util/storage/DefaultStorageSerializationManager.java +++ b/src/dorkbox/util/storage/DefaultStorageSerializationManager.java @@ -25,7 +25,7 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import com.esotericsoftware.minlog.Log; -import dorkbox.util.SerializationManager; +import dorkbox.util.serialization.SerializationManager; import io.netty.buffer.ByteBuf; class DefaultStorageSerializationManager implements SerializationManager { @@ -41,6 +41,13 @@ class DefaultStorageSerializationManager implements SerializationManager { return this; } + @Override + public + SerializationManager register(final Class clazz, final int id) { + kryo.register(clazz, id); + return this; + } + @Override public SerializationManager register(final Class clazz, final Serializer serializer) { diff --git a/src/dorkbox/util/storage/DiskStorage.java b/src/dorkbox/util/storage/DiskStorage.java index d40d66d..c7974fd 100644 --- a/src/dorkbox/util/storage/DiskStorage.java +++ b/src/dorkbox/util/storage/DiskStorage.java @@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import org.slf4j.Logger; import dorkbox.util.DelayTimer; -import dorkbox.util.SerializationManager; +import dorkbox.util.serialization.SerializationManager; /** diff --git a/src/dorkbox/util/storage/Metadata.java b/src/dorkbox/util/storage/Metadata.java index 8e63452..87919b4 100644 --- a/src/dorkbox/util/storage/Metadata.java +++ b/src/dorkbox/util/storage/Metadata.java @@ -25,7 +25,7 @@ import java.nio.channels.FileLock; import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; -import dorkbox.util.SerializationManager; +import dorkbox.util.serialization.SerializationManager; public class Metadata { diff --git a/src/dorkbox/util/storage/StorageBase.java b/src/dorkbox/util/storage/StorageBase.java index 5cb63b5..6ca7e4e 100644 --- a/src/dorkbox/util/storage/StorageBase.java +++ b/src/dorkbox/util/storage/StorageBase.java @@ -38,7 +38,7 @@ import com.esotericsoftware.kryo.io.Input; import com.esotericsoftware.kryo.io.Output; import dorkbox.util.OS; -import dorkbox.util.SerializationManager; +import dorkbox.util.serialization.SerializationManager; // a note on file locking between c and java diff --git a/src/dorkbox/util/storage/StorageSystem.java b/src/dorkbox/util/storage/StorageSystem.java index 30d97a9..90f92bf 100644 --- a/src/dorkbox/util/storage/StorageSystem.java +++ b/src/dorkbox/util/storage/StorageSystem.java @@ -26,7 +26,7 @@ import org.slf4j.helpers.NOPLogger; import dorkbox.util.FileUtil; import dorkbox.util.OS; -import dorkbox.util.SerializationManager; +import dorkbox.util.serialization.SerializationManager; public class StorageSystem {