Repository: ignite Updated Branches: refs/heads/ignite-2100 [created] 0d72b7e7c
IGNITE-2100: API. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0d72b7e7 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0d72b7e7 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0d72b7e7 Branch: refs/heads/ignite-2100 Commit: 0d72b7e7c7cd580b41d48f1bb18c3f38b579a240 Parents: 6d7a6ea Author: vozerov-gridgain <[email protected]> Authored: Thu Dec 10 16:31:09 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Thu Dec 10 16:31:09 2015 +0300 ---------------------------------------------------------------------- .../ignite/binary/BinaryTypeConfiguration.java | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/0d72b7e7/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java index a694eaf..dbe6973 100644 --- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java @@ -17,10 +17,14 @@ package org.apache.ignite.binary; +import org.apache.ignite.internal.portable.BinaryMarshaller; +import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.BinaryConfiguration; +import java.io.Externalizable; + /** * Defines configuration properties for a specific binary type. Providing per-type * configuration is optional, as it is generally enough, and also optional, to provide global binary @@ -29,6 +33,9 @@ import org.apache.ignite.configuration.BinaryConfiguration; * binary type without affecting configuration for other binary types. */ public class BinaryTypeConfiguration { + /** Default value of "use default serialization" flag. */ + public static final boolean DFLT_USE_DFLT_SER = false; + /** Class name. */ private String typeName; @@ -41,13 +48,32 @@ public class BinaryTypeConfiguration { /** Enum flag. */ private boolean isEnum; + /** Use default serialization flag. */ + private boolean useDfltSer = DFLT_USE_DFLT_SER; + /** + * Constructor. */ public BinaryTypeConfiguration() { // No-op. } /** + * Copying constructor. + * + * @param other Other instance. + */ + public BinaryTypeConfiguration(BinaryTypeConfiguration other) { + A.notNull(other, "other"); + + typeName = other.typeName; + idMapper = other.idMapper; + serializer = other.serializer; + isEnum = other.isEnum; + useDfltSer = other.useDfltSer; + } + + /** * @param typeName Class name. */ public BinaryTypeConfiguration(String typeName) { @@ -126,6 +152,34 @@ public class BinaryTypeConfiguration { this.isEnum = isEnum; } + /** + * Gets whether to use default serialization. + * <p> + * {@link BinaryMarshaller} allows for objects to be used without deserialization. To achieve this fields metadata + * is written along with their values. When default Java serialization mechanisms, such as {@link Externalizable} + * or {@code writeObject()} method, are used, there is no way to get this metadata. For this reason by default + * {@code BinaryMarshaller} ignores these mechanisms and writes all non-transient fields directly. + * <p> + * Sometimes you might want to disable this behavior and fallback to default serialization. Set value of this flag + * to {@code true} to achieve this. + * <p> + * Defaults to {@link #DFLT_USE_DFLT_SER}. + * + * @return {@code True} if default serialization should be used. + */ + public boolean isUseDefaultSerialization() { + return useDfltSer; + } + + /** + * Sets whether to use default serialization. See {@link #isUseDefaultSerialization()} for details. + * + * @param useDfltSer {@code True} if default serialization should be used. + */ + public void setUseDefaultSerialization(boolean useDfltSer) { + this.useDfltSer = useDfltSer; + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(BinaryTypeConfiguration.class, this, super.toString());
