1 19 20 package org.apache.cayenne.remote.hessian; 21 22 import java.util.HashMap ; 23 24 import com.caucho.hessian.io.AbstractSerializerFactory; 25 import com.caucho.hessian.io.Deserializer; 26 import com.caucho.hessian.io.HessianProtocolException; 27 import com.caucho.hessian.io.Serializer; 28 29 38 class EnumSerializerFactory extends AbstractSerializerFactory { 39 40 private final EnumSerializer enumSerializer = new EnumSerializer(); 41 private HashMap <Class , Deserializer> cachedDeserializerMap; 42 43 public Serializer getSerializer(Class cl) throws HessianProtocolException { 44 return (cl.isEnum()) ? enumSerializer : null; 45 } 46 47 public Deserializer getDeserializer(Class cl) throws HessianProtocolException { 48 if (cl.isEnum()) { 49 Deserializer deserializer = null; 50 51 synchronized (this) { 52 53 if (cachedDeserializerMap != null) { 54 deserializer = cachedDeserializerMap.get(cl); 55 } 56 57 if (deserializer == null) { 58 deserializer = new EnumDeserializer(cl); 59 60 if (cachedDeserializerMap == null) { 61 cachedDeserializerMap = new HashMap <Class , Deserializer>(); 62 } 63 64 cachedDeserializerMap.put(cl, deserializer); 65 } 66 } 67 68 return deserializer; 69 } 70 71 return null; 72 } 73 } 74 | Popular Tags |