diff --git a/java/fury-core/src/main/java/org/apache/fury/AbstractThreadSafeFury.java b/java/fury-core/src/main/java/org/apache/fury/AbstractThreadSafeFury.java index abe663c23d..6656a0477d 100644 --- a/java/fury-core/src/main/java/org/apache/fury/AbstractThreadSafeFury.java +++ b/java/fury-core/src/main/java/org/apache/fury/AbstractThreadSafeFury.java @@ -21,8 +21,11 @@ import java.util.function.Consumer; import java.util.function.Function; + +import org.apache.fury.config.Language; import org.apache.fury.serializer.Serializer; import org.apache.fury.serializer.SerializerFactory; +import org.apache.fury.util.Preconditions; public abstract class AbstractThreadSafeFury implements ThreadSafeFury { @Override @@ -30,19 +33,24 @@ public void register(Class clz) { processCallback(fury -> fury.register(clz)); } + @Override + public void register(Class cls, int id) { + processCallback(fury -> fury.register(cls, id)); + } + @Override public void register(Class cls, boolean createSerializer) { processCallback(fury -> fury.register(cls, createSerializer)); } @Override - public void register(Class cls, int id) { - processCallback(fury -> fury.register(cls, id)); + public void register(Class cls, String typeName) { + processCallback(fury -> fury.register(cls, typeName)); } @Override - public void register(Class cls, int id, boolean createSerializer) { - processCallback(fury -> fury.register(cls, id, createSerializer)); + public void register(Class cls, String namespace, String typeName) { + processCallback(fury -> fury.register(cls, namespace, typeName)); } @Override diff --git a/java/fury-core/src/main/java/org/apache/fury/BaseFury.java b/java/fury-core/src/main/java/org/apache/fury/BaseFury.java index 83bf4bf250..c4e4972bd7 100644 --- a/java/fury-core/src/main/java/org/apache/fury/BaseFury.java +++ b/java/fury-core/src/main/java/org/apache/fury/BaseFury.java @@ -21,6 +21,8 @@ import java.io.OutputStream; import java.util.function.Function; + +import org.apache.fury.config.Language; import org.apache.fury.io.FuryInputStream; import org.apache.fury.io.FuryReadableChannel; import org.apache.fury.memory.MemoryBuffer; @@ -28,6 +30,7 @@ import org.apache.fury.serializer.Serializer; import org.apache.fury.serializer.SerializerFactory; import org.apache.fury.serializer.Serializers; +import org.apache.fury.util.Preconditions; /** All Fury’s basic interface, including Fury’s basic methods. */ public interface BaseFury { @@ -41,6 +44,9 @@ public interface BaseFury { */ void register(Class cls); + /** register class with given id. */ + void register(Class cls, int id); + /** * Register class and allocate an auto-grown ID for this class. Note that the registration order * is important. If registration order is inconsistent, the allocated ID will be different, and @@ -52,9 +58,6 @@ public interface BaseFury { */ void register(Class cls, boolean createSerializer); - /** register class with given id. */ - void register(Class cls, int id); - /** * Register class with specified id. * @@ -65,6 +68,12 @@ public interface BaseFury { */ void register(Class cls, int id, boolean createSerializer); + /** register class with given type name which will be used for cross-language serialization. */ + void register(Class cls, String typeName); + + /** register class with given type namespace and name which will be used for cross-language serialization. */ + void register(Class cls, String namespace, String typeName); + /** * Register a Serializer for a class, and allocate an auto-grown ID for this class if it's not * registered yet. Note that the registration order is important. If registration order is diff --git a/java/fury-core/src/main/java/org/apache/fury/Fury.java b/java/fury-core/src/main/java/org/apache/fury/Fury.java index 808c0754cb..316487342f 100644 --- a/java/fury-core/src/main/java/org/apache/fury/Fury.java +++ b/java/fury-core/src/main/java/org/apache/fury/Fury.java @@ -147,20 +147,20 @@ public void register(Class cls) { } @Override - public void register(Class cls, boolean createSerializer) { + public void register(Class cls, int id) { if (language == Language.JAVA) { - classResolver.register(cls, createSerializer); + classResolver.register(cls, id); } else { - xtypeResolver.register(cls); + xtypeResolver.register(cls, id); } } @Override - public void register(Class cls, int id) { + public void register(Class cls, boolean createSerializer) { if (language == Language.JAVA) { - classResolver.register(cls, id); + classResolver.register(cls, createSerializer); } else { - xtypeResolver.register(cls, id); + xtypeResolver.register(cls); } } @@ -173,13 +173,11 @@ public void register(Class cls, int id, boolean createSerializer) { } } - /** register class with given type tag which will be used for cross-language serialization. */ public void register(Class cls, String typeName) { Preconditions.checkArgument(language != Language.JAVA); register(cls, "", typeName); } - /** register class with given type tag which will be used for cross-language serialization. */ public void register(Class cls, String namespace, String typeName) { Preconditions.checkArgument(language != Language.JAVA); xtypeResolver.register(cls, namespace, typeName);