All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.client.hotrod.marshall;

import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.protostream.ProtobufUtil;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.config.Configuration;
import org.infinispan.query.remote.client.BaseProtoStreamMarshaller;

/**
 * A marshaller that uses Protocol Buffers.
 *
 * @author [email protected]
 * @since 6.0
 */
public class ProtoStreamMarshaller extends BaseProtoStreamMarshaller {

   private final SerializationContext serializationContext = ProtobufUtil.newSerializationContext(Configuration.builder().build());

   public ProtoStreamMarshaller() {
   }

   @Override
   public SerializationContext getSerializationContext() {
      return serializationContext;
   }

   /**
    * Obtains the {@link SerializationContext} associated with the given remote cache manager.
    *
    * @param remoteCacheManager the remote cache manager (must not be {@code null})
    * @return the associated {@link SerializationContext}
    * @throws HotRodClientException if the cache manager is not configured to use a {@link ProtoStreamMarshaller}
    */
   public static SerializationContext getSerializationContext(RemoteCacheManager remoteCacheManager) {
      Marshaller marshaller = remoteCacheManager.getMarshaller();
      if (marshaller instanceof ProtoStreamMarshaller) {
         return ((ProtoStreamMarshaller) marshaller).getSerializationContext();
      }
      throw new HotRodClientException("The cache manager must be configured with a ProtoStreamMarshaller");
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy