Package org.infinispan.loaders.remote

Source Code of org.infinispan.loaders.remote.InternalCacheEntryMarshaller

package org.infinispan.loaders.remote;

import org.infinispan.client.hotrod.HotRodMarshaller;
import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.infinispan.marshall.Marshaller;

import java.io.IOException;

/**
* Marshaller used internally by the remote cache store.
*
* @author Mircea.Markus@jboss.com
* @since 4.1
*/
public class InternalCacheEntryMarshaller implements HotRodMarshaller {

   public final Marshaller marshaller;

   public InternalCacheEntryMarshaller(Marshaller marshaller) {
      this.marshaller = marshaller;
   }

   @Override
   public byte[] marshallObject(Object toMarshall) {
      try {
         return marshaller.objectToByteBuffer(toMarshall);
      } catch (IOException e) {
         throw new HotRodClientException(e);
      }
   }

   @Override
   public Object readObject(byte[] bytes) {
      try {
         return marshaller.objectFromByteBuffer(bytes);
      } catch (Exception e) {
         throw new HotRodClientException(e);
      }
   }
}
TOP

Related Classes of org.infinispan.loaders.remote.InternalCacheEntryMarshaller

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.