package org.infinispan.demo;

import org.infinispan.Cache;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.StorageType;
import org.infinispan.demo.model.Person;
import org.infinispan.demo.model.SerializablePerson;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;

public class BasicMarshalling {
    
    public static void main(String[] args) {
        storeBinary();
        //storeObject();
        //storeOffHeap();
    }
    
    private static void storeBinary() {
        Configuration conf = new ConfigurationBuilder().memory().storageType(StorageType.BINARY).build();
        EmbeddedCacheManager ecm = new DefaultCacheManager(conf);
        Cache<String, SerializablePerson> cache = ecm.getCache();

        cache.put("person", new SerializablePerson("name", "surname"));
        System.out.printf("Cache size: %d\n", cache.size());
        System.out.printf("Person %s\n", cache.get("person"));
        ecm.stop();
    }
    
    private static void storeObject() {
        Configuration conf = new ConfigurationBuilder().memory().storageType(StorageType.OBJECT).build();
        EmbeddedCacheManager ecm = new DefaultCacheManager(conf);
        Cache<String, Person> cache = ecm.getCache();

        cache.put("person", new Person("name", "surname"));
        System.out.printf("Cache size: %d\n", cache.size());
        System.out.printf("Person %s\n", cache.get("person"));
        ecm.stop();
    }
    
    private static void storeOffHeap() {
        Configuration conf = new ConfigurationBuilder().memory().storageType(StorageType.OFF_HEAP).build();
        EmbeddedCacheManager ecm = new DefaultCacheManager(conf);
        Cache<String, SerializablePerson> cache = ecm.getCache();

        cache.put("person", new SerializablePerson("name", "surname"));
        System.out.printf("Cache size: %d\n", cache.size());
        System.out.printf("Person %s\n", cache.get("person"));
        ecm.stop();
    }
    
}

@@ -535,26 +535,24 @@
 ();%0A        
-//
 storeObject(
@@ -566,10 +566,8 @@
     
-//
 stor
@@ -932,32 +932,78 @@
 %22, %22surname%22));%0A
+        System.out.println(%22BINARY storage%22);%0A
         System.o
@@ -1460,32 +1460,78 @@
 %22, %22surname%22));%0A
+        System.out.println(%22OBJECT storage%22);%0A
         System.o
@@ -1943,32 +1943,32 @@
 cm.getCache();%0A%0A
-
         cache.pu
@@ -2015,32 +2015,80 @@
 %22, %22surname%22));%0A
+        System.out.println(%22OFF-HEAP storage%22);%0A
         System.o

Print object storage and run all storage types