Search in sources :

Example 6 with NamespaceConfig

use of io.atomix.utils.serializer.NamespaceConfig in project atomix by atomix.

the class AtomicDocumentTreeBuilder method serializer.

/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
    if (serializer == null) {
        NamespaceConfig namespaceConfig = this.config.getNamespaceConfig();
        if (namespaceConfig == null) {
            namespaceConfig = new NamespaceConfig();
        }
        SerializerBuilder serializerBuilder = managementService.getSerializationService().newBuilder(name);
        serializerBuilder.withNamespace(new Namespace(namespaceConfig));
        if (config.isRegistrationRequired()) {
            serializerBuilder.withRegistrationRequired();
        }
        if (config.isCompatibleSerialization()) {
            serializerBuilder.withCompatibleSerialization();
        }
        if (config.getNodeType() != null) {
            serializerBuilder.addType(config.getNodeType());
        }
        if (!config.getExtraTypes().isEmpty()) {
            serializerBuilder.withTypes(config.getExtraTypes().toArray(new Class<?>[config.getExtraTypes().size()]));
        }
        serializer = serializerBuilder.build();
    }
    return serializer;
}
Also used : NamespaceConfig(io.atomix.utils.serializer.NamespaceConfig) SerializerBuilder(io.atomix.utils.serializer.SerializerBuilder) Namespace(io.atomix.utils.serializer.Namespace)

Example 7 with NamespaceConfig

use of io.atomix.utils.serializer.NamespaceConfig in project atomix by atomix.

the class PrimitiveBuilder method serializer.

/**
 * Returns the protocol serializer.
 *
 * @return the protocol serializer
 */
protected Serializer serializer() {
    Serializer serializer = this.serializer;
    if (serializer == null) {
        synchronized (this) {
            serializer = this.serializer;
            if (serializer == null) {
                NamespaceConfig config = this.config.getNamespaceConfig();
                if (config == null) {
                    serializer = Serializer.using(Namespaces.BASIC);
                } else {
                    serializer = Serializer.using(Namespace.builder().register(Namespaces.BASIC).nextId(Namespaces.BEGIN_USER_CUSTOM_ID).register(new Namespace(config)).build());
                }
                this.serializer = serializer;
            }
        }
    }
    return serializer;
}
Also used : NamespaceConfig(io.atomix.utils.serializer.NamespaceConfig) Namespace(io.atomix.utils.serializer.Namespace) Serializer(io.atomix.utils.serializer.Serializer)

Aggregations

Namespace (io.atomix.utils.serializer.Namespace)7 NamespaceConfig (io.atomix.utils.serializer.NamespaceConfig)7 SerializerBuilder (io.atomix.utils.serializer.SerializerBuilder)6 Serializer (io.atomix.utils.serializer.Serializer)1