package org.craft.atom.protocol.rpc;

import org.craft.atom.protocol.rpc.model.RpcBody;
import org.craft.atom.protocol.rpc.spi.Serialization;
import org.craft.atom.protocol.rpc.spi.SerializationFactory;

/**
 * @author mindwind
 * @version 1.0, Jul 23, 2014
 */
public class KryoSerializationFactory implements SerializationFactory<RpcBody> {
	
	
	private static final KryoSerializationFactory INSTNACE = new KryoSerializationFactory();
	private KryoSerializationFactory() {}
	public static KryoSerializationFactory getInstance() { return INSTNACE; } 
    

	@Override
	public Serialization<RpcBody> newSerialization() {
		return new KryoSerialization();
	}
	
}

@@ -340,16 +340,30 @@
 %3E %7B%0A%09%0A%09%0A
+%09// singleton%0A
 %09private
@@ -444,16 +444,16 @@
 tory();%0A
-
 %09private
@@ -563,12 +563,265 @@
  %7D %0A
-    
+%09%0A%09%0A%09// thread local cache%0A    private static final ThreadLocal%3CKryoSerialization%3E CACHE = new ThreadLocal%3CKryoSerialization%3E() %7B%0A    %09@Override%0A    %09protected KryoSerialization initialValue() %7B%0A            return new KryoSerialization();%0A        %7D%0A    %7D;%0A%09
 %0A%0A%09@
@@ -890,37 +890,25 @@
 %09return 
-new KryoSerialization
+CACHE.get
 ();%0A%09%7D%0A%09

improve - performance