Package org.infinispan.io

Examples of org.infinispan.io.MarshalledValueByteStream


    */
   private MarshalledValueByteStream serialize(Object instance) {
      try {
         // Do NOT set instance to null over here, since it may be used elsewhere (e.g., in a cache listener).
         // this will be compacted by the MarshalledValueInterceptor when the call returns.
         MarshalledValueByteStream baos = new ExpandableMarshalledValueByteStream(this.serialisedSize);
         ObjectOutput out = marshaller.startObjectOutput(baos, true, this.serialisedSize);
         try {
            marshaller.objectToObjectStream(instance, out);
         } finally {
            marshaller.finishObjectOutput(out);
View Full Code Here


      if (o == null || MarshalledValue.class != o.getClass()) {
         return false;
      }

      MarshalledValue that = (MarshalledValue) o;
      MarshalledValueByteStream thisRaw = this.raw;
      MarshalledValueByteStream thatRaw = that.raw;
      if (thisRaw != null && thatRaw != null) return thisRaw.equals(thatRaw);

      return false;
   }
View Full Code Here

      }

      @Override
      public void writeObject(ObjectOutput output, MarshalledValue mv) throws IOException {
         int hashCode = mv.hashCode();
         MarshalledValueByteStream raw = mv.getRaw();
         int rawLength = raw.size();
         UnsignedNumeric.writeUnsignedInt(output, rawLength);
         output.write(raw.getRaw(), 0, rawLength);
         output.writeInt(hashCode);
      }
View Full Code Here

   /**
    * Should only be called from a synchronized method
    */
   private MarshalledValueByteStream serialize0() {
      MarshalledValueByteStream localRaw = raw;
      if (localRaw == null) {
         try {
            // Do NOT set instance to null over here, since it may be used elsewhere (e.g., in a cache listener).
            // this will be compacted by the MarshalledValueInterceptor when the call returns.
            MarshalledValueByteStream baos = new ExpandableMarshalledValueByteStream(this.serialisedSize);
            ObjectOutput out = marshaller.startObjectOutput(baos, true, this.serialisedSize);
            try {
               marshaller.objectToObjectStream(instance, out);
            } finally {
               marshaller.finishObjectOutput(out);
            }
            serialisedSize = baos.size();
            localRaw = baos;
            raw = baos;
         } catch (Exception e) {
            throw new CacheException("Unable to marshall value " + instance, e);
         }
View Full Code Here

    */
   public synchronized void compact(boolean preferSerializedRepresentation, boolean force) {
      // reset the equalityPreference
      equalityPreferenceForInstance = true;
      Object thisInstance = this.instance;
      MarshalledValueByteStream thisRaw = this.raw;
      if (force) {
         if (preferSerializedRepresentation && thisRaw == null) {
            // Accessing a synchronized method from an already synchronized
            // method is expensive, so delegate to a private not synched method.
            thisRaw = serialize0();
View Full Code Here

         }
      }
   }

   public MarshalledValueByteStream getRaw() {
      MarshalledValueByteStream rawValue = raw;
      if (rawValue == null){
         rawValue = serialize();
      }
      return rawValue;
   }
View Full Code Here

      Object thisInstance = this.instance;
      Object thatInstance = that.instance;
      //test the default equality first so we might skip some work:
      if (preferInstanceEquality && thisInstance != null && thatInstance != null) return thisInstance.equals(thatInstance);

      MarshalledValueByteStream thisRaw = this.raw;
      MarshalledValueByteStream thatRaw = that.raw;
      if (thisRaw != null && thatRaw != null) return thisRaw.equals(thatRaw);
      if (thisInstance != null && thatInstance != null) return thisInstance.equals(thatInstance);

      // if conversion of one representation to the other is necessary, then see which we prefer converting.
      if (preferInstanceEquality) {
View Full Code Here

         this.globalMarshaller = globalMarshaller;
      }

      @Override
      public void writeObject(ObjectOutput output, MarshalledValue mv) throws IOException {
         MarshalledValueByteStream raw = mv.getRaw();
         int rawLength = raw.size();
         UnsignedNumeric.writeUnsignedInt(output, rawLength);
         output.write(raw.getRaw(), 0, rawLength);
         output.writeInt(mv.hashCode());
      }
View Full Code Here

   /**
    * Should only be called from a synchronized method
    */
   private MarshalledValueByteStream serialize0() {
      MarshalledValueByteStream localRaw = raw;
      if (localRaw == null) {
         try {
            // Do NOT set instance to null over here, since it may be used elsewhere (e.g., in a cache listener).
            // this will be compacted by the MarshalledValueInterceptor when the call returns.
            MarshalledValueByteStream baos = new ExpandableMarshalledValueByteStream(this.serialisedSize);
            ObjectOutput out = marshaller.startObjectOutput(baos, true, this.serialisedSize);
            try {
               marshaller.objectToObjectStream(instance, out);
            } finally {
               marshaller.finishObjectOutput(out);
            }
            serialisedSize = baos.size();
            localRaw = baos;
            raw = baos;
         } catch (Exception e) {
            throw new CacheException("Unable to marshall value " + instance, e);
         }
View Full Code Here

    */
   public synchronized void compact(boolean preferSerializedRepresentation, boolean force) {
      // reset the equalityPreference
      equalityPreferenceForInstance = true;
      Object thisInstance = this.instance;
      MarshalledValueByteStream thisRaw = this.raw;
      if (force) {
         if (preferSerializedRepresentation && thisRaw == null) {
            // Accessing a synchronized method from an already synchronized
            // method is expensive, so delegate to a private not synched method.
            thisRaw = serialize0();
View Full Code Here

TOP

Related Classes of org.infinispan.io.MarshalledValueByteStream

Copyright © 2018 www.massapicom. 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.