Changeset 53 for trunk/src/main/java/omq/common/util/Serializer.java
- Timestamp:
- 06/20/13 16:57:39 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main/java/omq/common/util/Serializer.java
r49 r53 4 4 import java.util.Properties; 5 5 6 import org.apache.log4j.Logger;7 8 import omq.common.broker.Broker;9 6 import omq.common.event.Event; 10 7 import omq.common.message.Request; … … 23 20 */ 24 21 public class Serializer { 25 private static final Logger logger = Logger.getLogger(Serializer.class.getName()); 26 public static String kryo = "kryo"; 27 public static String java = "java"; 28 public static String gson = "gson"; 22 // private static final Logger logger = 23 // Logger.getLogger(Serializer.class.getName()); 24 public static final String kryo = "kryo"; 25 public static final String java = "java"; 26 public static final String gson = "gson"; 29 27 30 28 // Client serializer 31 public staticISerializer serializer;29 public ISerializer serializer; 32 30 33 31 // Server serializers 34 private staticISerializer kryoSerializer;35 private staticISerializer javaSerializer;36 private staticISerializer gsonSerializer;32 private ISerializer kryoSerializer; 33 private ISerializer javaSerializer; 34 private ISerializer gsonSerializer; 37 35 38 private static Boolean getEnableCompression() { 39 Properties env = Broker.getEnvironment(); 36 private Properties env; 37 38 public Serializer(Properties env) { 39 this.env = env; 40 } 41 42 private Boolean getEnableCompression() { 40 43 return Boolean.valueOf(env.getProperty(ParameterQueue.ENABLECOMPRESSION, "false")); 41 44 } 42 45 43 public staticISerializer getInstance() throws SerializerException {46 public ISerializer getInstance() throws SerializerException { 44 47 if (serializer == null) { 45 48 try { 46 Properties env = Broker.getEnvironment();47 49 String className = env.getProperty(ParameterQueue.SERIALIZER_NAME, Serializer.java); 48 50 … … 60 62 } 61 63 62 public staticISerializer getInstance(String type) throws SerializerException {64 public ISerializer getInstance(String type) throws SerializerException { 63 65 if (kryo.equals(type)) { 64 66 if (kryoSerializer == null) { … … 79 81 } 80 82 81 public staticbyte[] serialize(String type, Object obj) throws SerializerException {83 public byte[] serialize(String type, Object obj) throws SerializerException { 82 84 ISerializer instance = getInstance(type); 83 85 … … 96 98 97 99 // TODO: remove this function and think about the event serialization 98 public staticbyte[] serialize(Object obj) throws SerializerException {100 public byte[] serialize(Object obj) throws SerializerException { 99 101 ISerializer instance = getInstance(); 100 102 … … 112 114 } 113 115 114 public staticRequest deserializeRequest(String type, byte[] bytes, RemoteObject obj) throws SerializerException {116 public Request deserializeRequest(String type, byte[] bytes, RemoteObject obj) throws SerializerException { 115 117 ISerializer instance = getInstance(type); 116 118 … … 128 130 } 129 131 130 public staticResponse deserializeResponse(byte[] bytes, Class<?> type) throws SerializerException {132 public Response deserializeResponse(byte[] bytes, Class<?> type) throws SerializerException { 131 133 ISerializer instance = getInstance(); 132 134 … … 144 146 } 145 147 146 public staticEvent deserializeEvent(byte[] bytes) throws SerializerException {148 public Event deserializeEvent(byte[] bytes) throws SerializerException { 147 149 ISerializer instance = getInstance(); 148 150 … … 160 162 } 161 163 162 public static void removeSerializers() {163 164 165 166 167 168 }164 // public static void removeSerializers() { 165 // logger.warn("Removing serializers"); 166 // serializer = null; 167 // kryoSerializer = null; 168 // javaSerializer = null; 169 // gsonSerializer = null; 170 // } 169 171 }
Note: See TracChangeset
for help on using the changeset viewer.