4 Replies Latest reply: Jan 27, 2013 6:21 PM by robvarga RSS

    implement PofSerializer, serialize/deserialize not invoked

    987089
      Hi,

      I have an object of a certain type that I want to put in coherence and a serializer for this type which implements PofSerializer. When I put/get the object to/from coherence, I expect serialize/deserialize methods to be called. But I have breakpoints in the serializer class and I can see that these overridden methods are not invoked. Can you help me with that? I will put the classes and configurations here:
      public class Item extends CacheItem {
           private String guid;
           private String cvc;
           
           public String getGuid() {
                return guid;
           }
           public void setGuid(String guid) {
                this.guid = guid;
           }
           public String getCvc() {
                return cvc;
           }
           public void setCvc(String cvc) {
                this.cvc = cvc;
           }
      }
      The serializer:
      public class CacheItemSerializer implements PofSerializer {
      
           @Override
           public Object deserialize(PofReader reader) throws IOException {
                Item item = new CardCacheItem();
                item.setCvc(reader.readString(0));
                item.setGuid(reader.readString(1));
                item.setAcc(reader.readInt(2));
                item.setAm(reader.readDouble(3));
                reader.readRemainder();
                return item;
           }
      
           @Override
           public void serialize(PofWriter writer, Object o) throws IOException {
                Item item = (Item) o;
                writer.writeString(0, item.getCvc());
                writer.writeString(0, item.getGuid());
                writer.writeInt(2, item.getAcc());
                writer.writeDouble(3, item.getAm());
                writer.writeRemainder(null);
           }
      } 
      In these two methods above I have breakpoints and they are not invoked.

      The pof-config.xml file:
      <user-type-list>
            <include>coherence-pof-config.xml</include>
      
            <!-- User types must be above 1000 -->
            <user-type>
               <type-id>2001</type-id>
                  <class-name>com.betfair.site.coherence.entities.Item</class-name>
                  <serializer>
                      <class-name>com.betfair.site.coherence.serializers.CacheItemSerializer</class-name>
                  </serializer>
              </user-type>
          </user-type-list>
      I initialize the cache like this:
      CacheFactory.ensureCluster();
      namedCache = CacheFactory.getCache(cacheName);
      And then call put/get on the namedCache object.

      I have the following arguments set:
      -Dtangosol.pof.enabled=true
      -Dtangosol.pof.config=pof-config.xml
      And in the console I see that it loads the pof file.

      That's about all the configuration I make. Am I missing something?

      Edited by: user11200171 on Jan 25, 2013 1:03 PM